Commit 14be1b89 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 3aabde32 b7e2e62f
......@@ -219,7 +219,7 @@ class RegistrationTest(TestCase, RegistrationTestMixin):
# Check database models
user = User.objects.get(username='username')
self.assertEquals(
self.assertEqual(
VerifiedEmail.objects.filter(social__user=user).count(), 2
)
self.assertTrue(
......
......@@ -261,7 +261,7 @@ class VerifyPluralsTest(TestCase):
# Get maximal plural
nplurals = max([plural(x) for x in range(200)]) + 1
# Check it matches ours
self.assertEquals(
self.assertEqual(
nplurals,
language.nplurals,
'Invalid nplurals for {0}: {1} ({2}, {3})'.format(
......
......@@ -262,20 +262,23 @@ class UnitManager(models.Manager):
"""
Finds closely similar units.
"""
queue = multiprocessing.Queue()
proc = multiprocessing.Process(
target=more_like_queue,
args=(unit.checksum, unit.source, top, queue)
)
proc.start()
proc.join(appsettings.MT_WEBLATE_LIMIT)
if proc.is_alive():
proc.terminate()
if appsettings.MT_WEBLATE_LIMIT >= 0:
queue = multiprocessing.Queue()
proc = multiprocessing.Process(
target=more_like_queue,
args=(unit.checksum, unit.source, top, queue)
)
proc.start()
proc.join(appsettings.MT_WEBLATE_LIMIT)
if proc.is_alive():
proc.terminate()
if queue.empty():
raise Exception('Request timed out.')
if queue.empty():
raise Exception('Request timed out.')
more_results = queue.get()
more_results = queue.get()
else:
more_results = more_like(unit.checksum, unit.source, top)
same_results = fulltext_search(
unit.get_source_plurals()[0],
......
......@@ -45,7 +45,7 @@ class ACLViewTest(ViewTestCase):
response = self.client.get(
reverse('project', kwargs=self.kw_project)
)
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
def test_acl(self):
"""Regular user should not have access to user management.
......
......@@ -35,7 +35,7 @@ class ChartsTest(ViewTestCase):
"""
Tests whether response has valid json chart data.
"""
self.assertEquals(response.get('Content-Type'), 'application/json')
self.assertEqual(response.get('Content-Type'), 'application/json')
data = json.loads(response.content)
self.assertTrue('series' in data)
self.assertTrue('labels' in data)
......
......@@ -745,14 +745,16 @@ class WhiteboardMessageTest(TestCase):
WhiteboardMessage()
class SourceTest(RepoTestCase):
"""
Source objects testing.
"""
class ModelTestCase(RepoTestCase):
def setUp(self):
super(SourceTest, self).setUp()
super(ModelTestCase, self).setUp()
self.create_subproject()
class SourceTest(ModelTestCase):
"""
Source objects testing.
"""
def test_exists(self):
self.assertTrue(Source.objects.exists())
......@@ -773,10 +775,29 @@ class SourceTest(RepoTestCase):
"""
Setting of Source check_flags changes checks for related units.
"""
self.assertEquals(Check.objects.count(), 1)
self.assertEqual(Check.objects.count(), 1)
check = Check.objects.all()[0]
unit = get_related_units(check)[0]
source = unit.source_info
source.check_flags = 'ignore-{0}'.format(check.check)
source.save()
self.assertEquals(Check.objects.count(), 0)
self.assertEqual(Check.objects.count(), 0)
class UnitTest(ModelTestCase):
@OverrideSettings(MT_WEBLATE_LIMIT=15)
def test_more_like(self):
unit = Unit.objects.all()[0]
self.assertEqual(Unit.objects.more_like_this(unit).count(), 0)
@OverrideSettings(MT_WEBLATE_LIMIT=0)
def test_more_like_timeout(self):
unit = Unit.objects.all()[0]
self.assertRaisesMessage(
Exception, 'Request timed out.', Unit.objects.more_like_this, unit
)
@OverrideSettings(MT_WEBLATE_LIMIT=-1)
def test_more_like_no_fork(self):
unit = Unit.objects.all()[0]
self.assertEqual(Unit.objects.more_like_this(unit).count(), 0)
......@@ -208,7 +208,7 @@ class VCSGitTest(RepoTestCase):
['testfile']
)
# Check we have new revision
self.assertNotEquals(
self.assertNotEqual(
oldrev,
self.repo.last_revision
)
......
......@@ -188,7 +188,7 @@ class ViewTestCase(RepoTestCase):
# Check response status code
self.assertEqual(response.status_code, 200)
dom = minidom.parseString(response.content)
self.assertEquals(dom.firstChild.nodeName, 'svg')
self.assertEqual(dom.firstChild.nodeName, 'svg')
def assertBackend(self, expected_translated):
'''
......@@ -907,8 +907,8 @@ class SourceStringsTest(ViewTestCase):
self.assertRedirects(response, source.get_absolute_url())
unit = self.get_unit()
self.assertEquals(unit.priority, 60)
self.assertEquals(unit.source_info.priority, 60)
self.assertEqual(unit.priority, 60)
self.assertEqual(unit.source_info.priority, 60)
def test_edit_check_flags(self):
# Need extra power
......@@ -923,7 +923,7 @@ class SourceStringsTest(ViewTestCase):
self.assertRedirects(response, source.get_absolute_url())
unit = self.get_unit()
self.assertEquals(unit.source_info.check_flags, 'ignore-same')
self.assertEqual(unit.source_info.check_flags, 'ignore-same')
def test_review_source(self):
response = self.client.get(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment