Fix issue with task shortcodes
Part of the code assumed shortcodes were globally unique, and another part assumed the shortcodes are unique per project (the latter is correct). Now the project ID is taken from the URL the Subversion hook pushes to.
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
import bson
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import logging.config
|
||||
import unittest
|
||||
|
||||
from dateutil.tz import tzutc
|
||||
import mock
|
||||
import svn.common
|
||||
|
||||
from pillar.tests import common_test_data as ctd
|
||||
|
||||
import logging_config
|
||||
from attract import subversion
|
||||
from abstract_attract_test import AbstractAttractTest
|
||||
|
||||
SVN_SERVER_URL = 'svn://biserver/agent327'
|
||||
@@ -26,7 +13,6 @@ class ShortcodeTest(AbstractAttractTest):
|
||||
self.proj_id, self.project = self.ensure_project_exists()
|
||||
|
||||
def test_increment_simple(self):
|
||||
|
||||
from attract import shortcodes
|
||||
|
||||
with self.app.test_request_context():
|
||||
@@ -36,3 +22,19 @@ class ShortcodeTest(AbstractAttractTest):
|
||||
with self.app.test_request_context():
|
||||
code = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'č')
|
||||
self.assertEqual('č2', code)
|
||||
|
||||
def test_multiple_projects(self):
|
||||
from attract import shortcodes
|
||||
|
||||
proj_id2, project2 = self.ensure_project_exists(project_overrides={
|
||||
'_id': bson.ObjectId(24 * 'f'),
|
||||
'url': 'proj2',
|
||||
})
|
||||
|
||||
with self.app.app_context():
|
||||
code1 = shortcodes.generate_shortcode(self.proj_id, 'jemoeder', 'č')
|
||||
code2 = shortcodes.generate_shortcode(proj_id2, 'jemoeder', 'č')
|
||||
code3 = shortcodes.generate_shortcode(proj_id2, 'jemoeder', 'č')
|
||||
self.assertEqual('č1', code1)
|
||||
self.assertEqual('č1', code2)
|
||||
self.assertEqual('č2', code3)
|
||||
|
Reference in New Issue
Block a user