Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed May 14, 2015
2 parents 3aabde3 + b7e2e62 commit 14be1b8
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 28 deletions.
2 changes: 1 addition & 1 deletion weblate/accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_add_mail(self):

# Check database models
user = User.objects.get(username='username')
self.assertEquals(
self.assertEqual(
VerifiedEmail.objects.filter(social__user=user).count(), 2
)
self.assertTrue(
Expand Down
2 changes: 1 addition & 1 deletion weblate/lang/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_equation(self):
# 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(
Expand Down
27 changes: 15 additions & 12 deletions weblate/trans/models/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,23 @@ def more_like_this(self, unit, top=5):
"""
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],
Expand Down
2 changes: 1 addition & 1 deletion weblate/trans/tests/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_acl_denied(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion weblate/trans/tests/test_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def assert_json_chart_data(self, response):
"""
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)
Expand Down
35 changes: 28 additions & 7 deletions weblate/trans/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,16 @@ def test_can_be_imported(self):
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())

Expand All @@ -773,10 +775,29 @@ def test_check_flags(self):
"""
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)
2 changes: 1 addition & 1 deletion weblate/trans/tests/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_commit(self):
['testfile']
)
# Check we have new revision
self.assertNotEquals(
self.assertNotEqual(
oldrev,
self.repo.last_revision
)
Expand Down
8 changes: 4 additions & 4 deletions weblate/trans/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def assertSVG(self, response):
# 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):
'''
Expand Down Expand Up @@ -907,8 +907,8 @@ def test_edit_priority(self):
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
Expand All @@ -923,7 +923,7 @@ def test_edit_check_flags(self):
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(
Expand Down

0 comments on commit 14be1b8

Please sign in to comment.