diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d5b49d..335e6bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,20 +11,24 @@ jobs: runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.11, 3.12] + services: - postgres: - image: postgres - ports: - - 5432 + mariadb: + image: mariadb:11.7.2 env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: 'postgres' - POSTGRES_DB: editgroups + MARIADB_DATABASE: editgroups + MARIADB_ROOT_PASSWORD: editgroups + ports: + - 3306 options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 + --health-cmd="healthcheck.sh --connect --innodb_initialized" + --health-interval=10s + --health-timeout=5s + --health-retries=3 redis: image: redis ports: @@ -36,20 +40,32 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.11 - uses: actions/setup-python@v2 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 with: - python-version: 3.11 + python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install -r requirements.txt - pip install psycopg2-binary==2.9.7 coveralls + pip install mysqlclient==2.2.7 coveralls pip freeze echo "from .dev import *" > editgroups/settings/__init__.py - cat editgroups/settings/secret_gh_action.py | sed -e "s/POSTGRES_PORT/${{ job.services.postgres.ports[5432] }}/g" | sed -e "s/REDIS_REAL_PORT/${{ job.services.redis.ports[6379] }}/g" > editgroups/settings/secret.py - - name: Run Django tests + cat editgroups/settings/secret_gh_action.py | sed -e "s/MARIADB_PORT/${{ job.services.mariadb.ports[3306] }}/g" | sed -e "s/REDIS_REAL_PORT/${{ job.services.redis.ports[6379] }}/g" > editgroups/settings/secret.py + + - name: Verify MariaDB connection + env: + PORT: ${{ job.services.mariadb.ports[3306] }} + run: | + while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do + sleep 1 + done + + - name: Run tests run: | coverage run --source=editgroups,store,revert,tagging --omit=*/migrations/*,edtigroups/settings/* manage.py test -v 2 env: diff --git a/editgroups/settings/secret_gh_action.py b/editgroups/settings/secret_gh_action.py index 9841449..4d2f797 100644 --- a/editgroups/settings/secret_gh_action.py +++ b/editgroups/settings/secret_gh_action.py @@ -3,17 +3,18 @@ SECRET_KEY = '20oj&tj8uaruseitlrise,tries,uirsetur36746209etus7e' # Database -# https://docs.djangoproject.com/en/1.7/ref/settings/#databases - DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'editgroups', - 'USER': 'postgres', - 'PASSWORD': 'postgres', - 'HOST': 'localhost', - 'PORT': 'POSTGRES_PORT', - 'DISABLE_SERVER_SIDE_CURSORS': False, + 'ENGINE': 'django.db.backends.mysql', + 'HOST': '127.0.0.1', + 'PORT': 'MARIADB_PORT', + 'NAME': 'editgroups', + 'USER': 'root', + 'PASSWORD': 'editgroups', + 'OPTIONS': { + 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", + 'charset': 'utf8mb4', + }, } } diff --git a/revert/tests.py b/revert/tests.py index 9c49af4..3684046 100644 --- a/revert/tests.py +++ b/revert/tests.py @@ -43,13 +43,13 @@ def test_revert_not_logged_in(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(401, response.status_code) + self.assertEqual(401, response.status_code) def test_revert_invalid_batch(self): response = self.client.post( reverse('submit-revert', args=['NOTATOOL', 'uster']), data={'comment':'testing reverts'}) - self.assertEquals(404, response.status_code) + self.assertEqual(404, response.status_code) def test_revert_batch_already_reverted(self): Edit.objects.all().update(reverted=True) @@ -59,7 +59,7 @@ def test_revert_batch_already_reverted(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(400, response.status_code) + self.assertEqual(400, response.status_code) def test_revert_batch_archived(self): b = Batch.objects.get() @@ -68,38 +68,38 @@ def test_revert_batch_archived(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(400, response.status_code) + self.assertEqual(400, response.status_code) def test_revert_batch_already_being_reverted(self): task = RevertTask(batch=self.batch, user=self.mary, comment="Already reverting") task.save() batch = Batch.objects.get(id=self.batch.id) - self.assertEquals(task, batch.active_revert_task) + self.assertEqual(task, batch.active_revert_task) response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(400, response.status_code) + self.assertEqual(400, response.status_code) def test_revert_batch_no_summary(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={}) - self.assertEquals(400, response.status_code) + self.assertEqual(400, response.status_code) @patch.object(RevertTask, 'revert_edit', fake_revert) def test_revert_batch_fine(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(302, response.status_code) + self.assertEqual(302, response.status_code) def test_initiate_revert_fine(self): response = self.client.get( reverse('initiate-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(200, response.status_code) + self.assertEqual(200, response.status_code) @patch.object(RevertTask, 'revert_edit', fake_revert) def test_revert_batch_previous_canceled(self): @@ -109,8 +109,8 @@ def test_revert_batch_previous_canceled(self): response = self.client.post( reverse('submit-revert', args=[self.batch.tool.shortid, self.batch.uid]), data={'comment':'testing reverts'}) - self.assertEquals(302, response.status_code) - self.assertEquals(2, RevertTask.objects.count()) + self.assertEqual(302, response.status_code) + self.assertEqual(2, RevertTask.objects.count()) def test_stop_not_logged_in(self): self.client.logout() @@ -118,19 +118,19 @@ def test_stop_not_logged_in(self): task.save() response = self.client.post( reverse('stop-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(401, response.status_code) + self.assertEqual(401, response.status_code) def test_stop_no_task(self): response = self.client.post( reverse('stop-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(404, response.status_code) + self.assertEqual(404, response.status_code) def test_stop_different_user(self): task = RevertTask(batch=self.batch, user=self.john, comment="Already reverting") task.save() response = self.client.post( reverse('stop-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(403, response.status_code) + self.assertEqual(403, response.status_code) def test_stop_task_already_complete(self): task = RevertTask(batch=self.batch, user=self.mary, comment="Already reverting") @@ -138,27 +138,27 @@ def test_stop_task_already_complete(self): task.save() response = self.client.post( reverse('stop-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(404, response.status_code) + self.assertEqual(404, response.status_code) def test_stop_fine(self): task = RevertTask(batch=self.batch, user=self.mary, comment="Already reverting") task.save() response = self.client.post( reverse('stop-revert', args=[self.batch.tool.shortid, self.batch.uid])) - self.assertEquals(302, response.status_code) + self.assertEqual(302, response.status_code) task = RevertTask.objects.get(id=task.id) self.assertTrue(task.cancel) def test_oauth_tokens(self): task = RevertTask(batch=self.batch, user=self.mary, comment="Already reverting") - self.assertEquals({'oauth_token':'12345','oauth_token_secret':'67890'}, + self.assertEqual({'oauth_token':'12345','oauth_token_secret':'67890'}, task.oauth_tokens) def test_oauth_tokens_canceled(self): task = RevertTask(batch=self.batch, user=self.mary, comment="Already reverting") task.cancel = True with self.assertRaises(ValueError): - self.assertEquals({'oauth_token':'12345','oauth_token_secret':'67890'}, + self.assertEqual({'oauth_token':'12345','oauth_token_secret':'67890'}, task.oauth_tokens) def test_summary(self): diff --git a/store/tests.py b/store/tests.py index 14550fb..ce9abb1 100644 --- a/store/tests.py +++ b/store/tests.py @@ -27,27 +27,27 @@ def setUp(self): def test_or(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(('ca7d7cc', 'Pintoch', 'import Charity Navigator'), + self.assertEqual(('ca7d7cc', 'Pintoch', 'import Charity Navigator'), tool.match("Pintoch", "/* wbeditentity-update:0| */ import Charity Navigator ([[Wikidata:Edit groups/OR/ca7d7cc|discuss]])")) def test_match_without_summary(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(('ca7d7cc', 'Pintoch', ''), + self.assertEqual(('ca7d7cc', 'Pintoch', ''), tool.match("Pintoch", "/* wbeditentity-update:0| */ ([[Wikidata:Edit groups/OR/ca7d7cc|discuss]])")) def test_match_empty_id(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(None, + self.assertEqual(None, tool.match("Pintoch", "/* wbeditentity-update:0| */ ([[Wikidata:Edit groups/OR/|discuss]])")) def test_or_setclaim(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(('3990c0d', 'Pintoch', 'add EIN ids from Charity Navigator'), + self.assertEqual(('3990c0d', 'Pintoch', 'add EIN ids from Charity Navigator'), tool.match("Pintoch", "/* wbsetclaim-create:2||1 */ [[Property:P1297]]: 88-0302673, add EIN ids from Charity Navigator ([[:toollabs:editgroups/b/OR/3990c0d|details]])")) @@ -55,34 +55,34 @@ def test_or_setclaim(self): def test_qs(self): tool = Tool.objects.get(shortid='QSv2') - self.assertEquals(('2120', 'Pintoch', '#quickstatements'), + self.assertEqual(('2120', 'Pintoch', '#quickstatements'), tool.match("QuickStatementsBot", "/* wbcreateclaim-create:1| */ [[Property:P3896]]: Data:Neighbourhoods/New York City.map, #quickstatements; [[:toollabs:quickstatements/#mode=batch&batch=2120|batch #2120]] by [[User:Pintoch|]]")) def test_empty_user(self): tool = Tool.objects.get(shortid='QSv2') - self.assertEquals(('2120', 'QuickStatementsBot', '#quickstatements'), + self.assertEqual(('2120', 'QuickStatementsBot', '#quickstatements'), tool.match("QuickStatementsBot", "/* wbcreateclaim-create:1| */ [[Property:P3896]]: Data:Neighbourhoods/New York City.map, #quickstatements; [[:toollabs:quickstatements/#mode=batch&batch=2120|batch #2120]] by [[User:|]]")) def test_eg(self): tool = Tool.objects.get(shortid='EG') - self.assertEquals(('c367abf', 'Pintoch', 'this was just dumb'), + self.assertEqual(('c367abf', 'Pintoch', 'this was just dumb'), tool.match("Pintoch", "/* undo:0||1234|Rageux */ this was just dumb ([[:toollabs:editgroups/b/EG/c367abf|details]])")) # for deletions, undeletions - self.assertEquals(('c367abf', 'Pintoch', 'deleting gibberish items'), + self.assertEqual(('c367abf', 'Pintoch', 'deleting gibberish items'), tool.match("Pintoch", "deleting gibberish items ([[:toollabs:editgroups/b/EG/c367abf|details]])")) def test_nb_batches(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(tool.nb_batches, 0) + self.assertEqual(tool.nb_batches, 0) def test_nb_unique_users(self): tool = Tool.objects.get(shortid='OR') - self.assertEquals(tool.nb_unique_users, 0) + self.assertEqual(tool.nb_unique_users, 0) @@ -95,22 +95,22 @@ def setUp(self): def test_ingest_jsonlines_or(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals('OR', batch.tool.shortid) - self.assertEquals('Pintoch', batch.user) - self.assertEquals('ca7d7cc', batch.uid) - self.assertEquals(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) - self.assertEquals(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) - self.assertEquals(51, batch.nb_edits) - self.assertEquals(0, batch.nb_reverted_edits) - self.assertEquals(0, batch.nb_new_pages) - self.assertEquals('32.9', batch.editing_speed) + self.assertEqual('OR', batch.tool.shortid) + self.assertEqual('Pintoch', batch.user) + self.assertEqual('ca7d7cc', batch.uid) + self.assertEqual(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) + self.assertEqual(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) + self.assertEqual(51, batch.nb_edits) + self.assertEqual(0, batch.nb_reverted_edits) + self.assertEqual(0, batch.nb_new_pages) + self.assertEqual('32.9', batch.editing_speed) def test_recompute_stats(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) # Mess around with the editing statistics batch = Batch.objects.get() batch.nb_edits = 0 @@ -132,46 +132,46 @@ def test_duration(self): started=datetime(2018, 3, 3, 16, 39, 37, tzinfo=UTC), ended=datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), nb_edits=4) - self.assertEquals(b.duration, 3*24*3600) + self.assertEqual(b.duration, 3*24*3600) def test_ingest_eg(self): Edit.ingest_jsonlines('store/testdata/eg_revert.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals('EG', batch.tool.shortid) - self.assertEquals(0, batch.nb_reverted_edits) - self.assertEquals(0, batch.nb_new_pages) + self.assertEqual('EG', batch.tool.shortid) + self.assertEqual(0, batch.nb_reverted_edits) + self.assertEqual(0, batch.nb_new_pages) def test_ingest_twice(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') Edit.ingest_jsonlines('store/testdata/one_or_batch.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(51, batch.nb_edits) - self.assertEquals(0, batch.nb_reverted_edits) - self.assertEquals(0, batch.nb_new_pages) + self.assertEqual(51, batch.nb_edits) + self.assertEqual(0, batch.nb_reverted_edits) + self.assertEqual(0, batch.nb_new_pages) def test_ingest_new_items(self): Edit.ingest_jsonlines('store/testdata/qs_batch_with_new_items.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(82, batch.nb_edits) - self.assertEquals(9, batch.nb_new_pages) - self.assertEquals(9, batch.nb_pages) - self.assertEquals(0, batch.nb_existing_pages) - self.assertEquals(0, batch.nb_reverted_edits) + self.assertEqual(82, batch.nb_edits) + self.assertEqual(9, batch.nb_new_pages) + self.assertEqual(9, batch.nb_pages) + self.assertEqual(0, batch.nb_existing_pages) + self.assertEqual(0, batch.nb_reverted_edits) def test_ingest_new_items_twice(self): Edit.ingest_jsonlines('store/testdata/qs_batch_with_new_items.json') Edit.ingest_jsonlines('store/testdata/qs_batch_with_new_items.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(82, batch.nb_edits) - self.assertEquals(9, batch.nb_new_pages) - self.assertEquals(9, batch.nb_pages) - self.assertEquals(0, batch.nb_existing_pages) - self.assertEquals(0, batch.nb_reverted_edits) + self.assertEqual(82, batch.nb_edits) + self.assertEqual(9, batch.nb_new_pages) + self.assertEqual(9, batch.nb_pages) + self.assertEqual(0, batch.nb_existing_pages) + self.assertEqual(0, batch.nb_reverted_edits) def test_hijack(self): """ @@ -181,20 +181,20 @@ def test_hijack(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') Edit.ingest_jsonlines('store/testdata/hijack.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(51, batch.nb_edits) + self.assertEqual(51, batch.nb_edits) def test_archive(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') batch = Batch.objects.get() - self.assertEquals(51, batch.nb_edits) - self.assertEquals(0, batch.nb_new_pages) - self.assertEquals(130901, batch.total_diffsize) - self.assertEquals(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) - self.assertEquals(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) - self.assertEquals(51, batch.edits.count()) + self.assertEqual(51, batch.nb_edits) + self.assertEqual(0, batch.nb_new_pages) + self.assertEqual(130901, batch.total_diffsize) + self.assertEqual(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) + self.assertEqual(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) + self.assertEqual(51, batch.edits.count()) self.assertFalse(batch.archived) self.assertTrue(batch.can_be_reverted) @@ -208,21 +208,21 @@ def test_archive(self): batch = Batch.objects.get() # The correct statistics have been recomputed - self.assertEquals(51, batch.nb_edits) - self.assertEquals(0, batch.nb_new_pages) - self.assertEquals(130901, batch.total_diffsize) - self.assertEquals(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) - self.assertEquals(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) + self.assertEqual(51, batch.nb_edits) + self.assertEqual(0, batch.nb_new_pages) + self.assertEqual(130901, batch.total_diffsize) + self.assertEqual(datetime(2018, 3, 6, 16, 39, 37, tzinfo=UTC), batch.started) + self.assertEqual(datetime(2018, 3, 6, 16, 41, 10, tzinfo=UTC), batch.ended) self.assertTrue(batch.archived) self.assertFalse(batch.can_be_reverted) # Most edits were deleted - self.assertEquals(settings.EDITS_KEPT_AFTER_ARCHIVAL, batch.edits.count()) + self.assertEqual(settings.EDITS_KEPT_AFTER_ARCHIVAL, batch.edits.count()) # If we attempt to archive again, the statistics will not be recomputed batch.archive(self.batch_inspector) self.assertTrue(batch.archived) - self.assertEquals(51, batch.nb_edits) + self.assertEqual(51, batch.nb_edits) def test_archive_small_batch(self): # There is no point in archiving small batches @@ -247,60 +247,60 @@ def test_wrong_namespace(self): Only edits in the item and property namespaces are considered """ Edit.ingest_jsonlines('store/testdata/wrong_namespace.json') - self.assertEquals(0, Batch.objects.count()) + self.assertEqual(0, Batch.objects.count()) def test_ingest_jsonlines_qs(self): Edit.ingest_jsonlines('store/testdata/one_qs_batch.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals('QSv2', batch.tool.shortid) - self.assertEquals('Pintoch', batch.user) - self.assertEquals('2120', batch.uid) - self.assertEquals(datetime(2018, 3, 7, 16, 20, 12, tzinfo=UTC), batch.started) - self.assertEquals(datetime(2018, 3, 7, 16, 20, 14, tzinfo=UTC), batch.ended) - self.assertEquals(4, batch.nb_edits) - self.assertEquals(1, batch.nb_pages) + self.assertEqual('QSv2', batch.tool.shortid) + self.assertEqual('Pintoch', batch.user) + self.assertEqual('2120', batch.uid) + self.assertEqual(datetime(2018, 3, 7, 16, 20, 12, tzinfo=UTC), batch.started) + self.assertEqual(datetime(2018, 3, 7, 16, 20, 14, tzinfo=UTC), batch.ended) + self.assertEqual(4, batch.nb_edits) + self.assertEqual(1, batch.nb_pages) def test_reverts(self): Edit.ingest_jsonlines('store/testdata/qs_batch_with_reverts.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(5, batch.nb_edits) - self.assertEquals(2, batch.nb_reverted) - self.assertEquals(1, batch.nb_pages) + self.assertEqual(5, batch.nb_edits) + self.assertEqual(2, batch.nb_reverted) + self.assertEqual(1, batch.nb_pages) def test_deletions(self): Edit.ingest_jsonlines('store/testdata/new_items_deleted.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(1, batch.nb_new_pages) + self.assertEqual(1, batch.nb_new_pages) self.assertEqual(1, batch.nb_reverted) - self.assertEquals(1, batch.nb_pages) + self.assertEqual(1, batch.nb_pages) def test_deletion_batch(self): Edit.ingest_jsonlines('store/testdata/deletion_edit.json') - self.assertEquals(1, Batch.objects.count()) + self.assertEqual(1, Batch.objects.count()) batch = Batch.objects.get() - self.assertEquals(0, batch.nb_new_pages) + self.assertEqual(0, batch.nb_new_pages) self.assertEqual(0, batch.nb_reverted) def test_deletion_restore(self): Edit.ingest_jsonlines('store/testdata/deletion_restore.json') - self.assertEquals(2, Batch.objects.count()) + self.assertEqual(2, Batch.objects.count()) delete_batch = Edit.objects.get(changetype='delete').batch restore_batch = Edit.objects.get(changetype='restore').batch - self.assertEquals(1, delete_batch.nb_reverted) + self.assertEqual(1, delete_batch.nb_reverted) self.assertEqual(0, restore_batch.nb_reverted) self.assertEqual(1, restore_batch.nb_undeleted_new_pages) def test_new_deletion_restore_deletion(self): Edit.ingest_jsonlines('store/testdata/new_deletion_restore_deletion.json') - self.assertEquals(4, Batch.objects.count()) + self.assertEqual(4, Batch.objects.count()) new_batch = Edit.objects.get(changetype='new').batch restore_batch = Edit.objects.get(changetype='restore').batch - self.assertEquals(1, new_batch.nb_reverted) + self.assertEqual(1, new_batch.nb_reverted) self.assertEqual(1, restore_batch.nb_reverted) self.assertEqual(Edit.objects.filter(reverted=False).count(), 1) @@ -322,9 +322,9 @@ def test_str(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') edit = Edit.objects.all().order_by('timestamp')[0] - self.assertEquals('https://www.wikidata.org/w/index.php?diff={newrevid}&oldid={oldrevid}'.format( + self.assertEqual('https://www.wikidata.org/w/index.php?diff={newrevid}&oldid={oldrevid}'.format( newrevid=edit.newrevid, oldrevid=edit.oldrevid), edit.url) - self.assertEquals(''.format(url=edit.url), str(edit)) + self.assertEqual(''.format(url=edit.url), str(edit)) def test_current_lag(self): Edit.ingest_jsonlines('store/testdata/one_or_batch.json') @@ -342,7 +342,7 @@ def setUpClass(cls): cls.batch = Batch.objects.get() def test_nbpages(self): - self.assertEquals(51, self.batch.nb_pages) + self.assertEqual(51, self.batch.nb_pages) def test_avg_diffsize(self): self.assertTrue(2500 < self.batch.avg_diffsize) @@ -363,7 +363,7 @@ def test_stream(self): for idx, edit in enumerate(s.stream()): if idx > 10: break - self.assertEquals('wikidatawiki', edit['wiki']) + self.assertEqual('wikidatawiki', edit['wiki']) self.assertEqual(s.headers["User-Agent"], "EditGroups (https://www.wikidata.org/wiki/Wikidata:Edit_groups)") class PagesTest(TestCase):