diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,6 @@ build/ dist/ .hypothesis +.cache .pytest_cache +.tox/ diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,11 @@ include Makefile +include pytest.ini include requirements.txt include requirements-swh.txt +include requirements-test.txt +include tox.ini include version.txt +recursive-include swh/web/assets * recursive-include swh/web/static * recursive-include swh/web/templates * include swh/web/tests/browse/views/data/swh-logo.png diff --git a/Makefile.local b/Makefile.local --- a/Makefile.local +++ b/Makefile.local @@ -16,11 +16,6 @@ run-migrations: python3 swh/web/manage.py migrate 2>/dev/null -.PHONY: run-tests-migrations -run-tests-migrations: - rm -f swh/web/settings/testdb.sqlite3 2>/dev/null - django-admin migrate --settings=swh.web.settings.tests 2>/dev/null - run-django-webpack-devserver: run-migrations bash -c "trap 'trap - SIGINT SIGTERM ERR; kill %1' SIGINT SIGTERM ERR; npm run start-dev & cd swh/web && python3 manage.py runserver --nostatic" @@ -39,5 +34,4 @@ run-gunicorn-server: run-migrations gunicorn3 -b 127.0.0.1:5004 swh.web.wsgi -test: build-webpack-dev-no-verbose run-tests-migrations diff --git a/debian/control b/debian/control --- a/debian/control +++ b/debian/control @@ -15,7 +15,8 @@ python3-htmlmin, python3-magic (>= 0.3.0~), python3-lxml, - python3-nose, + python3-pytest, + python3-pytest-django, python3-pygments, python3-pypandoc, python3-requests, diff --git a/debian/rules b/debian/rules --- a/debian/rules +++ b/debian/rules @@ -1,10 +1,8 @@ #!/usr/bin/make -f export PYBUILD_NAME=swh.web -export PYBUILD_TEST_ARGS=--with-doctest -sv ./swh/web/tests -export PYBUILD_BEFORE_TEST=cd {build_dir}; python3 swh/web/manage.py migrate -export PYBUILD_AFTER_TEST=cd {build_dir}; rm -f swh/web/settings/testdb.sqlite3 -export DJANGO_SETTINGS_MODULE=swh.web.settings.tests +export PYBUILD_OPTION=--test-pytest +export PYBUILD_TEST_ARGS=./swh/web/tests %: dh $@ --with python3 --buildsystem=pybuild diff --git a/pytest.ini b/pytest.ini --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,6 @@ [pytest] -norecursedirs = docs node_modules +norecursedirs = docs node_modules .tox +DJANGO_SETTINGS_MODULE = swh.web.settings.tests +filterwarnings = + ignore:.*U.*mode is deprecated:DeprecationWarning + diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1 +1,3 @@ -nose +pytest +pytest-django + diff --git a/swh/web/browse/utils.py b/swh/web/browse/utils.py --- a/swh/web/browse/utils.py +++ b/swh/web/browse/utils.py @@ -85,7 +85,7 @@ mime_type = magic_result.mime_type encoding = magic_result.encoding break - except Exception as exc: + except Exception: # workaround an issue with the magic module who can fail # if detect_from_content is called multiple times in # a short amount of time @@ -134,7 +134,7 @@ filetype = service.lookup_content_filetype(query_string) language = service.lookup_content_language(query_string) license = service.lookup_content_license(query_string) - except Exception as e: + except Exception: pass mimetype = 'unknown' encoding = 'unknown' @@ -188,7 +188,7 @@ content_data['raw_data'] = \ content_data['raw_data'].decode(encoding)\ .encode('utf-8') - except Exception as e: + except Exception: pass else: # ensure display in content view diff --git a/swh/web/common/utils.py b/swh/web/common/utils.py --- a/swh/web/common/utils.py +++ b/swh/web/common/utils.py @@ -13,7 +13,7 @@ from dateutil import tz from django.core.cache import cache -from django.core import urlresolvers +from django.urls import reverse as django_reverse from django.http import QueryDict from swh.model.exceptions import ValidationError @@ -47,7 +47,7 @@ if kwargs: kwargs = {k: v for k, v in kwargs.items() if v is not None} - url = urlresolvers.reverse( + url = django_reverse( viewname, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app) diff --git a/swh/web/settings/tests.py b/swh/web/settings/tests.py --- a/swh/web/settings/tests.py +++ b/swh/web/settings/tests.py @@ -75,11 +75,5 @@ ALLOWED_HOSTS += ['testserver'] -# As nose is used as a test runner, we cannot benefit from the in-memory -# django test database used when running tests through '$ python3 manage.py test'. -# So instead use a different database file that will be created on the fly -# when running the tests. -DATABASES['default']['NAME'] = os.path.join(PROJECT_DIR, 'testdb.sqlite3') - # Silent DEBUG output when running unit tests LOGGING['handlers']['console']['level'] = 'INFO' diff --git a/swh/web/tests/__init__.py b/swh/web/tests/__init__.py --- a/swh/web/tests/__init__.py +++ b/swh/web/tests/__init__.py @@ -1,13 +0,0 @@ -# Copyright (C) 2017-2018 The Software Heritage developers -# See the AUTHORS file at the top-level directory of this distribution -# License: GNU General Public License version 3, or any later version -# See top-level LICENSE file for more information - -# this configuration is needed to successfully run the tests locally -# when calling 'make test' - -import django -import os - -os.environ["DJANGO_SETTINGS_MODULE"] = "swh.web.settings.tests" -django.setup() diff --git a/swh/web/tests/admin/test_origin_save.py b/swh/web/tests/admin/test_origin_save.py --- a/swh/web/tests/admin/test_origin_save.py +++ b/swh/web/tests/admin/test_origin_save.py @@ -42,82 +42,82 @@ def check_not_login(self, url): login_url = reverse('login', query_params={'next': url}) response = self.client.post(url) - self.assertEquals(response.status_code, 302) - self.assertEquals(unquote(response.url), login_url) + self.assertEqual(response.status_code, 302) + self.assertEqual(unquote(response.url), login_url) def test_add_authorized_origin_url(self): authorized_url = 'https://scm.adullact.net/anonscm/' - self.assertEquals(can_save_origin(authorized_url), - SAVE_REQUEST_PENDING) + self.assertEqual(can_save_origin(authorized_url), + SAVE_REQUEST_PENDING) url = reverse('admin-origin-save-add-authorized-url', kwargs={'origin_url': authorized_url}) self.check_not_login(url) - self.assertEquals(can_save_origin(authorized_url), - SAVE_REQUEST_PENDING) + self.assertEqual(can_save_origin(authorized_url), + SAVE_REQUEST_PENDING) self.client.login(username=_user_name, password=_user_password) response = self.client.post(url) - self.assertEquals(response.status_code, 200) - self.assertEquals(can_save_origin(authorized_url), - SAVE_REQUEST_ACCEPTED) + self.assertEqual(response.status_code, 200) + self.assertEqual(can_save_origin(authorized_url), + SAVE_REQUEST_ACCEPTED) def test_remove_authorized_origin_url(self): - self.assertEquals(can_save_origin(_authorized_origin_url), - SAVE_REQUEST_ACCEPTED) + self.assertEqual(can_save_origin(_authorized_origin_url), + SAVE_REQUEST_ACCEPTED) url = reverse('admin-origin-save-remove-authorized-url', kwargs={'origin_url': _authorized_origin_url}) self.check_not_login(url) - self.assertEquals(can_save_origin(_authorized_origin_url), - SAVE_REQUEST_ACCEPTED) + self.assertEqual(can_save_origin(_authorized_origin_url), + SAVE_REQUEST_ACCEPTED) self.client.login(username=_user_name, password=_user_password) response = self.client.post(url) - self.assertEquals(response.status_code, 200) - self.assertEquals(can_save_origin(_authorized_origin_url), - SAVE_REQUEST_PENDING) + self.assertEqual(response.status_code, 200) + self.assertEqual(can_save_origin(_authorized_origin_url), + SAVE_REQUEST_PENDING) def test_add_unauthorized_origin_url(self): unauthorized_url = 'https://www.yahoo./' - self.assertEquals(can_save_origin(unauthorized_url), - SAVE_REQUEST_PENDING) + self.assertEqual(can_save_origin(unauthorized_url), + SAVE_REQUEST_PENDING) url = reverse('admin-origin-save-add-unauthorized-url', kwargs={'origin_url': unauthorized_url}) self.check_not_login(url) - self.assertEquals(can_save_origin(unauthorized_url), - SAVE_REQUEST_PENDING) + self.assertEqual(can_save_origin(unauthorized_url), + SAVE_REQUEST_PENDING) self.client.login(username=_user_name, password=_user_password) response = self.client.post(url) - self.assertEquals(response.status_code, 200) - self.assertEquals(can_save_origin(unauthorized_url), - SAVE_REQUEST_REJECTED) + self.assertEqual(response.status_code, 200) + self.assertEqual(can_save_origin(unauthorized_url), + SAVE_REQUEST_REJECTED) def test_remove_unauthorized_origin_url(self): - self.assertEquals(can_save_origin(_unauthorized_origin_url), - SAVE_REQUEST_REJECTED) + self.assertEqual(can_save_origin(_unauthorized_origin_url), + SAVE_REQUEST_REJECTED) url = reverse('admin-origin-save-remove-unauthorized-url', kwargs={'origin_url': _unauthorized_origin_url}) self.check_not_login(url) - self.assertEquals(can_save_origin(_unauthorized_origin_url), - SAVE_REQUEST_REJECTED) + self.assertEqual(can_save_origin(_unauthorized_origin_url), + SAVE_REQUEST_REJECTED) self.client.login(username=_user_name, password=_user_password) response = self.client.post(url) - self.assertEquals(response.status_code, 200) - self.assertEquals(can_save_origin(_unauthorized_origin_url), - SAVE_REQUEST_PENDING) + self.assertEqual(response.status_code, 200) + self.assertEqual(can_save_origin(_unauthorized_origin_url), + SAVE_REQUEST_PENDING) @patch('swh.web.common.origin_save.scheduler') def test_accept_pending_save_request(self, mock_scheduler): @@ -128,9 +128,9 @@ 'origin_url': origin_url}) response = self.client.post(save_request_url, data={}, content_type='application/x-www-form-urlencoded') # noqa - self.assertEquals(response.status_code, 200) - self.assertEquals(response.data['save_request_status'], - SAVE_REQUEST_PENDING) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data['save_request_status'], + SAVE_REQUEST_PENDING) accept_request_url = reverse('admin-origin-save-request-accept', kwargs={'origin_type': origin_type, @@ -159,14 +159,14 @@ self.client.login(username=_user_name, password=_user_password) response = self.client.post(accept_request_url) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) response = self.client.get(save_request_url) - self.assertEquals(response.status_code, 200) - self.assertEquals(response.data[0]['save_request_status'], - SAVE_REQUEST_ACCEPTED) - self.assertEquals(response.data[0]['save_task_status'], - SAVE_TASK_NOT_YET_SCHEDULED) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data[0]['save_request_status'], + SAVE_REQUEST_ACCEPTED) + self.assertEqual(response.data[0]['save_task_status'], + SAVE_TASK_NOT_YET_SCHEDULED) def test_reject_pending_save_request(self): origin_type = 'git' @@ -176,9 +176,9 @@ 'origin_url': origin_url}) response = self.client.post(save_request_url, data={}, content_type='application/x-www-form-urlencoded') # noqa - self.assertEquals(response.status_code, 200) - self.assertEquals(response.data['save_request_status'], - SAVE_REQUEST_PENDING) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data['save_request_status'], + SAVE_REQUEST_PENDING) reject_request_url = reverse('admin-origin-save-request-reject', kwargs={'origin_type': origin_type, @@ -188,9 +188,9 @@ self.client.login(username=_user_name, password=_user_password) response = self.client.post(reject_request_url) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) response = self.client.get(save_request_url) - self.assertEquals(response.status_code, 200) - self.assertEquals(response.data[0]['save_request_status'], - SAVE_REQUEST_REJECTED) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data[0]['save_request_status'], + SAVE_REQUEST_REJECTED) diff --git a/swh/web/tests/api/test_apiresponse.py b/swh/web/tests/api/test_apiresponse.py --- a/swh/web/tests/api/test_apiresponse.py +++ b/swh/web/tests/api/test_apiresponse.py @@ -30,7 +30,7 @@ headers = compute_link_header( rv, options) - self.assertEquals(headers, { + self.assertEqual(headers, { 'Link': '; rel="next",; rel="previous"', }) @@ -42,7 +42,7 @@ headers = compute_link_header( rv, options) - self.assertEquals(headers, {}) + self.assertEqual(headers, {}) def test_compute_link_header_nothing_changed_2(self): rv = {'headers': {}} @@ -52,31 +52,31 @@ headers = compute_link_header( rv, options) - self.assertEquals(headers, {}) + self.assertEqual(headers, {}) class SWHTransformProcessorTest(SWHWebTestCase): def test_transform_only_return_results_1(self): rv = {'results': {'some-key': 'some-value'}} - self.assertEquals(transform(rv), {'some-key': 'some-value'}) + self.assertEqual(transform(rv), {'some-key': 'some-value'}) def test_transform_only_return_results_2(self): rv = {'headers': {'something': 'do changes'}, 'results': {'some-key': 'some-value'}} - self.assertEquals(transform(rv), {'some-key': 'some-value'}) + self.assertEqual(transform(rv), {'some-key': 'some-value'}) def test_transform_do_remove_headers(self): rv = {'headers': {'something': 'do changes'}, 'some-key': 'some-value'} - self.assertEquals(transform(rv), {'some-key': 'some-value'}) + self.assertEqual(transform(rv), {'some-key': 'some-value'}) def test_transform_do_nothing(self): rv = {'some-key': 'some-value'} - self.assertEquals(transform(rv), {'some-key': 'some-value'}) + self.assertEqual(transform(rv), {'some-key': 'some-value'}) class RendererTestCase(SWHWebTestCase): @@ -146,7 +146,7 @@ actual_data = filter_by_fields(request, input_data) # then - self.assertEquals(actual_data, input_data) + self.assertEqual(actual_data, input_data) @patch('swh.web.api.apiresponse.utils.filter_field_keys') def test_swh_filter_renderer_do_filter(self, mock_ffk): @@ -164,6 +164,6 @@ actual_data = filter_by_fields(request, input_data) # then - self.assertEquals(actual_data, {'a': 'some-data'}) + self.assertEqual(actual_data, {'a': 'some-data'}) mock_ffk.assert_called_once_with(input_data, {'a', 'c'}) diff --git a/swh/web/tests/api/views/test_content.py b/swh/web/tests/api/views/test_content.py --- a/swh/web/tests/api/views/test_content.py +++ b/swh/web/tests/api/views/test_content.py @@ -25,9 +25,9 @@ 'sha1_git:b04caf10e9535160d90e874b45aa426de762f19f/filetype/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'accepted_media_type': 'application/xml', 'encoding': 'ascii', 'id': '34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03', @@ -49,9 +49,9 @@ 'filetype/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No filetype information found for content ' 'sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03.' @@ -74,9 +74,9 @@ 'sha1_git:b04caf10e9535160d90e874b45aa426de762f19f/language/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'lang': 'lisp', 'id': '34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03', 'content_url': '/api/1/content/' @@ -97,9 +97,9 @@ '/language/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No language information found for content ' 'sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03.' @@ -122,9 +122,9 @@ rv = self.client.get('/api/1/content/symbol/foo/?last_sha1=sha1') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, [{ + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, [{ 'sha1': '34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03', 'name': 'foobar', 'kind': 'Haskell', @@ -165,9 +165,9 @@ '/api/1/content/symbol/foo/?last_sha1=prev-sha1&per_page=2') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_ctag) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, stub_ctag) self.assertTrue( rv['Link'] == '; rel="next"' or # noqa rv['Link'] == '; rel="next"' # noqa @@ -189,9 +189,9 @@ rv = self.client.get('/api/1/content/symbol/foo/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, [{ + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, [{ 'sha1': '67891b8614fcd89ccd17ca2b1d9e66c5b00a6d03', 'name': 'foo', 'kind': 'variable', @@ -220,9 +220,9 @@ rv = self.client.get('/api/1/content/symbol/bar/?last_sha1=hash') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No indexed raw content match expression \'bar\'.' }) @@ -245,9 +245,9 @@ 'sha1_git:b04caf10e9535160d90e874b45aa426de762f19f/ctags/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'id': '34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03', 'ctags': [], 'content_url': '/api/1/content/' @@ -272,9 +272,9 @@ 'sha1_git:b04caf10e9535160d90e874b45aa426de762f19f/license/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'licenses': ['No_license_found', 'Apache-2.0'], 'id': '34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03', 'tool_name': 'nomos', @@ -296,9 +296,9 @@ 'license/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No license information found for content ' 'sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03.' @@ -324,9 +324,9 @@ 'sha1_git:34571b8614fcd89ccd17ca2b1d9e66c5b00a6d03/provenance/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, [{ + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, [{ 'origin': 1, 'visit': 2, 'origin_url': '/api/1/origin/1/', @@ -355,9 +355,9 @@ 'provenance/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Content with sha1:40e71b8614fcd89ccd17ca2b1d9e6' '6c5b00a6d03 not found.' @@ -386,9 +386,9 @@ rv = self.client.get( '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'checksums': { 'blake2s256': '685395c5dc57cada459364f0946d3dd45bad5f' 'cbabc1048edb44380f1d31d0aa', @@ -423,9 +423,9 @@ '/api/1/content/sha256:83c0e67cc80f60caf1fcbec2d84b0ccd7968b3' 'be4735637006560c/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Content with sha256:83c0e67cc80f60caf1fcbec2d84b0ccd79' '68b3be4735637006560c not found.' @@ -448,10 +448,10 @@ 'be4735637006560c/', HTTP_ACCEPT='application/yaml') - self.assertEquals(rv.status_code, 404) + self.assertEqual(rv.status_code, 404) self.assertTrue('application/yaml' in rv['Content-Type']) - self.assertEquals(rv.data, { + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Content with sha256:83c0e67cc80f60caf1fcbec2d84b0ccd79' '68b3be4735637006560c not found.' @@ -472,9 +472,9 @@ '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03' '/raw/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Content sha1:40e71b8614fcd89ccd17ca2b1d9e6' '6c5b00a6d03 is not found.' @@ -497,15 +497,15 @@ '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03' '/raw/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/octet-stream') - self.assertEquals( + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/octet-stream') + self.assertEqual( rv['Content-disposition'], 'attachment; filename=content_sha1_' '40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03_raw') - self.assertEquals( + self.assertEqual( rv['Content-Type'], 'application/octet-stream') - self.assertEquals(rv.content, stub_content['data']) + self.assertEqual(rv.content, stub_content['data']) mock_service.lookup_content_raw.assert_called_once_with( 'sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03') @@ -526,14 +526,14 @@ '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03' '/raw/?filename=filename.txt') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/octet-stream') - self.assertEquals( + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/octet-stream') + self.assertEqual( rv['Content-disposition'], 'attachment; filename=filename.txt') - self.assertEquals( + self.assertEqual( rv['Content-Type'], 'application/octet-stream') - self.assertEquals(rv.content, stub_content['data']) + self.assertEqual(rv.content, stub_content['data']) mock_service.lookup_content_raw.assert_called_once_with( 'sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03') @@ -555,9 +555,9 @@ '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03' '/raw/') - self.assertEquals(rv.status_code, 403) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 403) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'ForbiddenExc', 'reason': 'Only textual content is available for download. ' 'Actual content mimetype is application/octet-stream.' @@ -581,9 +581,9 @@ '/api/1/content/sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03' '/raw/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Content sha1:40e71b8614fcd89ccd17ca2b1d9e66c5b00a6d03 ' 'is not available for download.' @@ -612,9 +612,9 @@ # when rv = self.client.get('/api/1/content/known/sha1:blah/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_result) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_result) mock_service.lookup_multiple_hashes.assert_called_once_with( [{'filename': None, 'sha1': 'sha1:blah'}]) @@ -642,9 +642,9 @@ rv = self.client.get('/api/1/content/known/sha1:halb,sha1_git:hello/', HTTP_ACCEPT='application/yaml') - self.assertEquals(rv.status_code, 200) + self.assertEqual(rv.status_code, 200) self.assertTrue('application/yaml' in rv['Content-Type']) - self.assertEquals(rv.data, expected_result) + self.assertEqual(rv.data, expected_result) mock_service.lookup_multiple_hashes.assert_called_once_with( [{'filename': None, 'sha1': 'sha1:halb'}, @@ -678,9 +678,9 @@ HTTP_ACCEPT='application/yaml' ) - self.assertEquals(rv.status_code, 200) + self.assertEqual(rv.status_code, 200) self.assertTrue('application/yaml' in rv['Content-Type']) - self.assertEquals(rv.data, expected_result) + self.assertEqual(rv.data, expected_result) @patch('swh.web.api.views.content.service') def test_api_check_content_known_not_found(self, mock_service): @@ -697,9 +697,9 @@ # when rv = self.client.get('/api/1/content/known/sha1:halb/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_result) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_result) mock_service.lookup_multiple_hashes.assert_called_once_with( [{'filename': None, 'sha1': 'sha1:halb'}]) diff --git a/swh/web/tests/api/views/test_directory.py b/swh/web/tests/api/views/test_directory.py --- a/swh/web/tests/api/views/test_directory.py +++ b/swh/web/tests/api/views/test_directory.py @@ -49,9 +49,9 @@ '18d8be353ed3480476f032475e7c233eff7371d5/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_directories) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_directories) mock_service.lookup_directory.assert_called_once_with( '18d8be353ed3480476f032475e7c233eff7371d5') @@ -66,9 +66,9 @@ '66618d8be353ed3480476f032475e7c233eff737/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Directory with sha1_git ' '66618d8be353ed3480476f032475e7c233eff737 not found.'}) @@ -92,9 +92,9 @@ '18d8be353ed3480476f032475e7c233eff7371d5/bla/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_dir) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_dir) mock_service.lookup_directory_with_path.assert_called_once_with( '18d8be353ed3480476f032475e7c233eff7371d5', 'bla') @@ -112,9 +112,9 @@ path = path.strip('/') # Path stripped of lead/trail separators # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': (('Entry with path %s relative to ' 'directory with sha1_git ' diff --git a/swh/web/tests/api/views/test_entity.py b/swh/web/tests/api/views/test_entity.py --- a/swh/web/tests/api/views/test_entity.py +++ b/swh/web/tests/api/views/test_entity.py @@ -22,9 +22,9 @@ rv = self.client.get('/api/1/entity/' '5f4d4c51-498a-4e28-88b3-b3e4e8396cba/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': "Entity with uuid '5f4d4c51-498a-4e28-88b3-b3e4e8396cba' not " + @@ -42,9 +42,9 @@ # when rv = self.client.get('/api/1/entity/uuid malformed/') - self.assertEquals(rv.status_code, 400) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 400) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'BadInputExc', 'reason': 'bad input: uuid malformed!'}) mock_service.lookup_entity_by_uuid.assert_called_once_with( @@ -84,8 +84,8 @@ rv = self.client.get('/api/1/entity' '/34bd6b1b-463f-43e5-a697-785107f598e4/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_entities) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_entities) mock_service.lookup_entity_by_uuid.assert_called_once_with( '34bd6b1b-463f-43e5-a697-785107f598e4') diff --git a/swh/web/tests/api/views/test_identifiers.py b/swh/web/tests/api/views/test_identifiers.py --- a/swh/web/tests/api/views/test_identifiers.py +++ b/swh/web/tests/api/views/test_identifiers.py @@ -39,8 +39,8 @@ 'scheme_version': 1 } - self.assertEquals(resp.status_code, 200) - self.assertEquals(resp.data, expected_result) + self.assertEqual(resp.status_code, 200) + self.assertEqual(resp.data, expected_result) def test_swh_id_resolve_invalid(self): rev_id_invalid = '96db9023b8_foo_50d6c108e9a3' @@ -49,7 +49,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) @patch('swh.web.api.views.identifiers.service') def test_swh_id_resolve_not_found(self, mock_service): @@ -62,4 +62,4 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) diff --git a/swh/web/tests/api/views/test_origin.py b/swh/web/tests/api/views/test_origin.py --- a/swh/web/tests/api/views/test_origin.py +++ b/swh/web/tests/api/views/test_origin.py @@ -38,9 +38,9 @@ # when rv = self.client.get('/api/1/origin/2/visits/') # then - self.assertEquals(rv.status_code, 400) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 400) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'ValueError', 'reason': 'voluntary error to check the bad request middleware.'}) @@ -53,9 +53,9 @@ # when rv = self.client.get('/api/1/origin/2/visits/') # then - self.assertEquals(rv.status_code, 503) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 503) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'StorageDBError', 'reason': 'An unexpected error occurred in the backend: ' @@ -71,9 +71,9 @@ # when rv = self.client.get('/api/1/origin/2/visits/') # then - self.assertEquals(rv.status_code, 503) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 503) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'StorageAPIError', 'reason': 'An unexpected error occurred in the api backend: ' @@ -115,9 +115,9 @@ # when rv = self.client.get('/api/1/origin/2/visits/?per_page=2&last_visit=3') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, [ + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, [ { 'date': 1293919200.0, 'origin': 2, @@ -157,9 +157,9 @@ # when rv = self.client.get('/api/1/origin/10/visit/100/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_origin_visit) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_origin_visit) mock_service.lookup_origin_visit.assert_called_once_with('10', '100') @@ -171,9 +171,9 @@ # when rv = self.client.get('/api/1/origin/1/visit/1000/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No visit 1000 for origin 1 found' }) @@ -194,9 +194,9 @@ rv = self.client.get('/api/1/origin/1234/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_origin) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_origin) mock_service.lookup_origin.assert_called_with({'id': '1234'}) @@ -219,9 +219,9 @@ '/ftp://some/url/to/origin/0/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_origin) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_origin) mock_service.lookup_origin.assert_called_with( {'url': 'ftp://some/url/to/origin/0/', @@ -236,9 +236,9 @@ rv = self.client.get('/api/1/origin/4321/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Origin with id 4321 not found.' }) diff --git a/swh/web/tests/api/views/test_origin_save.py b/swh/web/tests/api/views/test_origin_save.py --- a/swh/web/tests/api/views/test_origin_save.py +++ b/swh/web/tests/api/views/test_origin_save.py @@ -36,7 +36,7 @@ 'origin_url': 'https://github.com/torvalds/linux'}) # noqa response = self.client.post(url) - self.assertEquals(response.status_code, 400) + self.assertEqual(response.status_code, 400) def test_invalid_origin_url(self): url = reverse('api-save-origin', @@ -44,7 +44,7 @@ 'origin_url': 'bar'}) response = self.client.post(url) - self.assertEquals(response.status_code, 400) + self.assertEqual(response.status_code, 400) def check_created_save_request_status(self, mock_scheduler, origin_url, scheduler_task_status, @@ -218,7 +218,7 @@ SAVE_TASK_NOT_YET_SCHEDULED) sors = list(SaveOriginRequest.objects.filter(origin_type='git', origin_url=origin_url)) - self.assertEquals(len(sors), 1) + self.assertEqual(len(sors), 1) self.check_created_save_request_status(mock_scheduler, origin_url, 'next_run_scheduled', @@ -226,7 +226,7 @@ SAVE_TASK_SCHEDULED) sors = list(SaveOriginRequest.objects.filter(origin_type='git', origin_url=origin_url)) - self.assertEquals(len(sors), 1) + self.assertEqual(len(sors), 1) visit_date = datetime.now() + timedelta(hours=1) self.check_created_save_request_status(mock_scheduler, origin_url, @@ -236,7 +236,7 @@ visit_date=visit_date) sors = list(SaveOriginRequest.objects.filter(origin_type='git', origin_url=origin_url)) - self.assertEquals(len(sors), 2) + self.assertEqual(len(sors), 2) self.check_created_save_request_status(mock_scheduler, origin_url, 'disabled', @@ -244,4 +244,4 @@ SAVE_TASK_NOT_YET_SCHEDULED) sors = list(SaveOriginRequest.objects.filter(origin_type='git', origin_url=origin_url)) - self.assertEquals(len(sors), 3) + self.assertEqual(len(sors), 3) diff --git a/swh/web/tests/api/views/test_person.py b/swh/web/tests/api/views/test_person.py --- a/swh/web/tests/api/views/test_person.py +++ b/swh/web/tests/api/views/test_person.py @@ -25,9 +25,9 @@ rv = self.client.get('/api/1/person/198003/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_person) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, stub_person) @patch('swh.web.api.views.person.service') def test_api_person_not_found(self, mock_service): @@ -38,8 +38,8 @@ rv = self.client.get('/api/1/person/666/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Person with id 666 not found.'}) diff --git a/swh/web/tests/api/views/test_release.py b/swh/web/tests/api/views/test_release.py --- a/swh/web/tests/api/views/test_release.py +++ b/swh/web/tests/api/views/test_release.py @@ -50,9 +50,9 @@ rv = self.client.get('/api/1/release/%s/' % release_id) # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_release) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_release) mock_service.lookup_release.assert_called_once_with(release_id) @@ -94,9 +94,9 @@ rv = self.client.get('/api/1/release/%s/' % release) # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_release) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_release) mock_service.lookup_release.assert_called_once_with(release) @@ -109,9 +109,9 @@ rv = self.client.get('/api/1/release/c54e6473c71bbb716529/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Release with sha1_git c54e6473c71bbb716529 not found.' }) diff --git a/swh/web/tests/api/views/test_revision.py b/swh/web/tests/api/views/test_revision.py --- a/swh/web/tests/api/views/test_revision.py +++ b/swh/web/tests/api/views/test_revision.py @@ -83,9 +83,9 @@ '18d8be353ed3480476f032475e7c233eff7371d5/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(expected_revision, rv.data) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(expected_revision, rv.data) mock_service.lookup_revision.assert_called_once_with( '18d8be353ed3480476f032475e7c233eff7371d5') @@ -99,9 +99,9 @@ rv = self.client.get('/api/1/revision/12345/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Revision with sha1_git 12345 not found.'}) @@ -116,9 +116,9 @@ rv = self.client.get('/api/1/revision/18d8be353ed3480476f032475e7c2' '33eff7371d5/raw/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/octet-stream') - self.assertEquals(rv.content, b'synthetic revision message') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/octet-stream') + self.assertEqual(rv.content, b'synthetic revision message') mock_service.lookup_revision_message.assert_called_once_with( '18d8be353ed3480476f032475e7c233eff7371d5') @@ -134,13 +134,13 @@ '18d8be353ed3480476f032475e7c233eff7371d5/raw/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No message for revision'}) - self.assertEquals + self.assertEqual mock_service.lookup_revision_message.assert_called_once_with( '18d8be353ed3480476f032475e7c233eff7371d5') @@ -155,9 +155,9 @@ '18d8be353ed3480476f032475e7c233eff7371d5/raw/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'No revision found'}) @@ -171,8 +171,8 @@ rv = self.client.get('/api/1/revision/origin/123/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertIn('Revision with (origin_id: 123', rv.data['reason']) self.assertIn('not found', rv.data['reason']) self.assertEqual('NotFoundExc', rv.data['exception']) @@ -204,8 +204,8 @@ rv = self.client.get('/api/1/revision/origin/1/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, expected_revision) mock_service.lookup_revision_by.assert_called_once_with( @@ -237,8 +237,8 @@ '/branch/refs/origin/dev/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, expected_revision) mock_service.lookup_revision_by.assert_called_once_with( @@ -280,8 +280,8 @@ '/ts/1452591542/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, expected_revision) mock_service.lookup_revision_by.assert_called_once_with( @@ -321,8 +321,8 @@ 'January%201,%202047%20at%208:21:00AM/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, expected_revision) mock_service.lookup_revision_by.assert_called_once_with( @@ -368,7 +368,7 @@ 'some/path', '/api/1/revision/sha1/directory/') # then - self.assertEquals(actual_dir_content, { + self.assertEqual(actual_dir_content, { 'type': 'dir', 'revision': 'rev-id', 'path': 'some/path', @@ -398,7 +398,7 @@ limit=1000, with_data=True) # then - self.assertEquals(actual_dir_content, { + self.assertEqual(actual_dir_content, { 'type': 'file', 'revision': 'rev-id', 'path': 'some/path', @@ -426,8 +426,8 @@ '/directory/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'not found'}) @@ -454,8 +454,8 @@ rv = self.client.get('/api/1/revision/origin/3/directory/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertEqual(rv.data, expected_res) mock_revision_dir.assert_called_once_with({ @@ -511,10 +511,10 @@ 'b7e2a44e6/log/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_revisions) + self.assertEqual(rv.data, expected_revisions) self.assertFalse(rv.has_header('Link')) mock_service.lookup_revision_log.assert_called_once_with( @@ -539,11 +539,11 @@ 'b7e2a44e6/log/?per_page=25') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_revisions) - self.assertEquals(rv['Link'], - '; rel="next"') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_revisions) + self.assertEqual(rv['Link'], + '; rel="next"') mock_service.lookup_revision_log.assert_called_once_with( '8834ef7e7c357ce2af928115c6c6a42b7e2a44e6', 26) @@ -558,9 +558,9 @@ 'a42b7e2a44e6/log/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Revision with sha1_git' ' 8834ef7e7c357ce2af928115c6c6a42b7e2a44e6 not found.'}) @@ -657,9 +657,9 @@ '6ad1f978e/log/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(expected_revisions, rv.data) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(expected_revisions, rv.data) self.assertFalse(rv.has_header('Link')) mock_service.lookup_revision_log.assert_called_once_with( @@ -713,9 +713,9 @@ rv = self.client.get('/api/1/revision/origin/1/log/') # then - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, expected_revisions) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, expected_revisions) self.assertFalse(rv.has_header('Link')) mock_service.lookup_revision_log_by.assert_called_once_with( @@ -739,11 +739,11 @@ rv = self.client.get('/api/1/revision/origin/1/log/?per_page=25') # then - self.assertEquals(rv.status_code, 200) + self.assertEqual(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv['Content-Type'], 'application/json') self.assertIsNotNone(rv['Link']) - self.assertEquals(rv.data, expected_revisions) + self.assertEqual(rv.data, expected_revisions) mock_service.lookup_revision_log_by.assert_called_once_with( '1', 'refs/heads/master', None, 26) @@ -758,11 +758,11 @@ rv = self.client.get('/api/1/revision/origin/1/log/') # then - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') self.assertFalse(rv.has_header('Link')) - self.assertEquals(rv.data, {'exception': 'NotFoundExc', - 'reason': 'No revision'}) + self.assertEqual(rv.data, {'exception': 'NotFoundExc', + 'reason': 'No revision'}) mock_service.lookup_revision_log_by.assert_called_once_with( '1', 'refs/heads/master', None, 11) @@ -786,9 +786,9 @@ # then rv = self.client.get('/api/1/revision/883/prev/999/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'id': '883', 'url': '/api/1/revision/883/', 'history_url': '/api/1/revision/883/log/', @@ -811,9 +811,9 @@ # then rv = self.client.get('/api/1/revision/999/directory/some/path/to/dir/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'NotFoundExc', 'reason': 'Not found'}) @@ -855,9 +855,9 @@ # then rv = self.client.get('/api/1/revision/999/directory/some/path/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_dir) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, stub_dir) mock_rev_dir.assert_called_once_with( {'sha1_git': '999'}, @@ -884,9 +884,9 @@ url = '/api/1/revision/666/directory/some/other/path/' rv = self.client.get(url) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_content) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, stub_content) mock_rev_dir.assert_called_once_with( {'sha1_git': '666'}, 'some/other/path', url, with_data=False) diff --git a/swh/web/tests/api/views/test_snapshot.py b/swh/web/tests/api/views/test_snapshot.py --- a/swh/web/tests/api/views/test_snapshot.py +++ b/swh/web/tests/api/views/test_snapshot.py @@ -104,11 +104,11 @@ url = reverse('api-snapshot', kwargs={'snapshot_id': _snapshot_id}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') expected_data = _lookup_snapshot(_snapshot_id) expected_data = _enrich_snapshot_data(expected_data) - self.assertEquals(rv.data, expected_data) + self.assertEqual(rv.data, expected_data) def test_api_snapshot_paginated(self, mock_service): mock_service.lookup_snapshot.side_effect = _lookup_snapshot @@ -125,12 +125,12 @@ query_params={'branches_from': branches_from, 'branches_count': branches_count}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') expected_data = _lookup_snapshot(_snapshot_id, branches_from, branches_count) expected_data = _enrich_snapshot_data(expected_data) - self.assertEquals(rv.data, expected_data) + self.assertEqual(rv.data, expected_data) whole_snapshot['branches'].update(expected_data['branches']) branches_offset += branches_count @@ -140,16 +140,16 @@ kwargs={'snapshot_id': _snapshot_id}, query_params={'branches_from': next_branch, 'branches_count': branches_count}) # noqa - self.assertEquals(rv['Link'], '<%s>; rel="next"' % next_url) + self.assertEqual(rv['Link'], '<%s>; rel="next"' % next_url) else: self.assertFalse(rv.has_header('Link')) url = reverse('api-snapshot', kwargs={'snapshot_id': _snapshot_id}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, whole_snapshot) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, whole_snapshot) def test_api_snapshot_filtered(self, mock_service): mock_service.lookup_snapshot.side_effect = _lookup_snapshot @@ -160,12 +160,12 @@ kwargs={'snapshot_id': _snapshot_id}, query_params={'target_types': target_types}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') expected_data = _lookup_snapshot(_snapshot_id, target_types=target_types.split(',')) expected_data = _enrich_snapshot_data(expected_data) - self.assertEquals(rv.data, expected_data) + self.assertEqual(rv.data, expected_data) def test_api_snapshot_errors(self, mock_service): mock_service.lookup_snapshot.side_effect = \ @@ -174,7 +174,7 @@ url = reverse('api-snapshot', kwargs={'snapshot_id': '63ce369'}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 400) + self.assertEqual(rv.status_code, 400) mock_service.lookup_snapshot.side_effect = \ NotFoundExc('Snapshot not found!') @@ -183,4 +183,4 @@ url = reverse('api-snapshot', kwargs={'snapshot_id': snapshot_inexistent}) rv = self.client.get(url) - self.assertEquals(rv.status_code, 404) + self.assertEqual(rv.status_code, 404) diff --git a/swh/web/tests/api/views/test_stat.py b/swh/web/tests/api/views/test_stat.py --- a/swh/web/tests/api/views/test_stat.py +++ b/swh/web/tests/api/views/test_stat.py @@ -20,9 +20,9 @@ # when rv = self.client.get('/api/1/stat/counters/') # then - self.assertEquals(rv.status_code, 400) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 400) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'ValueError', 'reason': 'voluntary error to check the bad request middleware.'}) @@ -34,9 +34,9 @@ # when rv = self.client.get('/api/1/stat/counters/') # then - self.assertEquals(rv.status_code, 503) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 503) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'StorageDBError', 'reason': 'An unexpected error occurred in the backend: ' @@ -51,9 +51,9 @@ # when rv = self.client.get('/api/1/stat/counters/') # then - self.assertEquals(rv.status_code, 503) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, { + self.assertEqual(rv.status_code, 503) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, { 'exception': 'StorageAPIError', 'reason': 'An unexpected error occurred in the api backend: ' @@ -83,8 +83,8 @@ # when rv = self.client.get('/api/1/stat/counters/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_stats) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data, stub_stats) mock_service.stat_counters.assert_called_once_with() diff --git a/swh/web/tests/api/views/test_vault.py b/swh/web/tests/api/views/test_vault.py --- a/swh/web/tests/api/views/test_vault.py +++ b/swh/web/tests/api/views/test_vault.py @@ -39,10 +39,10 @@ url += '{}/'.format(obj_type_format) rv = self.client.post(url, {'email': 'test@test.mail'}) - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data, stub_cook) + self.assertEqual(rv.data, stub_cook) mock_service.vault_cook.assert_called_with( obj_type, hashutil.hash_to_bytes(TEST_OBJ_ID), @@ -50,9 +50,9 @@ rv = self.client.get(url + 'raw/') - self.assertEquals(rv.status_code, 200) - self.assertEquals(rv['Content-Type'], 'application/gzip') - self.assertEquals(rv.content, stub_fetch) + self.assertEqual(rv.status_code, 200) + self.assertEqual(rv['Content-Type'], 'application/gzip') + self.assertEqual(rv.content, stub_fetch) mock_service.vault_fetch.assert_called_with( obj_type, hashutil.hash_to_bytes(TEST_OBJ_ID)) @@ -67,17 +67,17 @@ url += '{}/'.format(obj_type_format) rv = self.client.post(url) - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data['exception'], 'NotFoundExc') + self.assertEqual(rv.data['exception'], 'NotFoundExc') mock_service.vault_cook.assert_called_with( obj_type, hashutil.hash_to_bytes(TEST_OBJ_ID), None) rv = self.client.get(url + 'raw/') - self.assertEquals(rv.status_code, 404) - self.assertEquals(rv['Content-Type'], 'application/json') - self.assertEquals(rv.data['exception'], 'NotFoundExc') + self.assertEqual(rv.status_code, 404) + self.assertEqual(rv['Content-Type'], 'application/json') + self.assertEqual(rv.data['exception'], 'NotFoundExc') mock_service.vault_fetch.assert_called_with( obj_type, hashutil.hash_to_bytes(TEST_OBJ_ID)) diff --git a/swh/web/tests/browse/views/test_content.py b/swh/web/tests/browse/views/test_content.py --- a/swh/web/tests/browse/views/test_content.py +++ b/swh/web/tests/browse/views/test_content.py @@ -45,7 +45,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') self.assertContains(resp, '') @@ -72,7 +72,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') self.assertContains(resp, '') @@ -105,7 +105,7 @@ try: resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') swh_cnt_id = get_swh_persistent_id('content', sha1_git) swh_cnt_id_url = reverse('browse-swh-id', @@ -129,7 +129,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') png_encoded = base64.b64encode(stub_content_bin_data['raw_data']) \ @@ -148,7 +148,7 @@ query_params={'path': stub_content_text_path_with_root_dir}) # noqa resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') self.assertContains(resp, '') @@ -196,7 +196,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertEqual(resp['Content-Type'], 'text/plain') self.assertEqual(resp['Content-disposition'], 'filename=%s_%s' % ('sha1', stub_content_text_data['checksums']['sha1'])) # noqa @@ -210,7 +210,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertEqual(resp['Content-Type'], 'text/plain') self.assertEqual(resp['Content-disposition'], 'filename=%s' % filename) @@ -232,7 +232,7 @@ kwargs={'query_string': non_utf8_encoded_content_data['checksums']['sha1']}) # noqa resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) _, encoding = get_mimetype_and_encoding_for_content(resp.content) self.assertEqual(encoding, non_utf8_encoding) @@ -245,7 +245,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertEqual(resp['Content-Type'], 'application/octet-stream') self.assertEqual(resp['Content-disposition'], 'attachment; filename=%s_%s' % @@ -258,7 +258,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertEqual(resp['Content-Type'], 'application/octet-stream') self.assertEqual(resp['Content-disposition'], 'attachment; filename=%s' % stub_content_bin_filename) @@ -269,7 +269,7 @@ url = reverse('browse-content', kwargs={'query_string': '123456'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) self.assertTemplateUsed('error.html') mock_request_content.side_effect = NotFoundExc('content not found') @@ -277,7 +277,7 @@ url = reverse('browse-content', kwargs={'query_string': stub_content_text_data['checksums']['sha1']}) # noqa resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') @patch('swh.web.browse.utils.service') @@ -293,7 +293,7 @@ kwargs={'query_string': content_data['checksums']['sha1']}) # noqa resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('browse/content.html') @patch('swh.web.browse.views.content.request_content') @@ -308,7 +308,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/content.html') self.assertContains(resp, 'Content is too large to be displayed') diff --git a/swh/web/tests/browse/views/test_directory.py b/swh/web/tests/browse/views/test_directory.py --- a/swh/web/tests/browse/views/test_directory.py +++ b/swh/web/tests/browse/views/test_directory.py @@ -35,7 +35,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/directory.html') self.assertContains(resp, '' + root_directory_sha1[:7] + '') @@ -121,7 +121,7 @@ kwargs={'sha1_git': '1253456'}) resp = self.client.get(dir_url) - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) self.assertTemplateUsed('browse/error.html') mock_utils_service.lookup_directory.side_effect = \ @@ -131,5 +131,5 @@ kwargs={'sha1_git': '1253456'}) resp = self.client.get(dir_url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('browse/error.html') diff --git a/swh/web/tests/browse/views/test_identifiers.py b/swh/web/tests/browse/views/test_identifiers.py --- a/swh/web/tests/browse/views/test_identifiers.py +++ b/swh/web/tests/browse/views/test_identifiers.py @@ -36,7 +36,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], content_browse_url) def test_directory_id_browse(self): @@ -49,7 +49,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], directory_browse_url) def test_revision_id_browse(self): @@ -62,7 +62,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], revision_browse_url) query_params = {'origin_type': 'git', @@ -77,7 +77,7 @@ query_params=query_params) resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], revision_browse_url) def test_release_id_browse(self): @@ -90,7 +90,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], release_browse_url) query_params = {'origin_type': 'git', @@ -105,7 +105,7 @@ query_params=query_params) resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], release_browse_url) def test_bad_id_browse(self): @@ -114,7 +114,7 @@ kwargs={'swh_id': swh_id}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) def test_content_id_optional_parts_browse(self): cnt_sha1_git = stub_content_text_data['checksums']['sha1_git'] @@ -131,6 +131,6 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 302) + self.assertEqual(resp.status_code, 302) self.assertEqual(resp['location'], content_browse_url) diff --git a/swh/web/tests/browse/views/test_origin.py b/swh/web/tests/browse/views/test_origin.py --- a/swh/web/tests/browse/views/test_origin.py +++ b/swh/web/tests/browse/views/test_origin.py @@ -85,14 +85,14 @@ 'origin_url': origin_info_test_data['url']}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('origin-visits.html') url = reverse('browse-origin-visits', kwargs={'origin_url': origin_info_test_data['url']}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('origin-visits.html') def origin_content_view_helper(self, origin_info, origin_visits, @@ -123,7 +123,7 @@ query_params=query_params) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('content.html') self.assertContains(resp, '' % content_language) @@ -223,7 +223,7 @@ query_params=query_params) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('content.html') swh_cnt_id = get_swh_persistent_id('content', content_sha1_git) @@ -336,10 +336,10 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('directory.html') - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('directory.html') @@ -643,7 +643,7 @@ kwargs={'origin_type': 'foo', 'origin_url': 'bar'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'origin not found', status_code=404) @@ -654,7 +654,7 @@ kwargs={'origin_type': 'foo', 'origin_url': 'bar'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, "No SWH visit", status_code=404) @@ -666,7 +666,7 @@ 'origin_url': 'bar'}, query_params={'visit_id': len(stub_origin_visits)+1}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertRegex(resp.content.decode('utf-8'), 'Visit.*not found') @@ -677,7 +677,7 @@ kwargs={'origin_type': 'foo', 'origin_url': 'bar'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertRegex(resp.content.decode('utf-8'), 'Origin.*has an empty list of branches') @@ -689,7 +689,7 @@ kwargs={'origin_type': 'foo', 'origin_url': 'bar'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Directory not found', status_code=404) @@ -701,7 +701,7 @@ 'origin_url': 'bar', 'path': 'foo'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, "No SWH visit", status_code=404) @@ -714,7 +714,7 @@ 'path': 'foo'}, query_params={'visit_id': len(stub_origin_visits)+1}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertRegex(resp.content.decode('utf-8'), 'Visit.*not found') @@ -726,7 +726,7 @@ 'origin_url': 'bar', 'path': 'baz'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertRegex(resp.content.decode('utf-8'), 'Origin.*has an empty list of branches') @@ -741,7 +741,7 @@ 'origin_url': 'bar', 'path': 'baz'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Content not found', status_code=404) @@ -755,7 +755,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('branches.html') origin_branches = origin_snapshot[0] @@ -826,7 +826,7 @@ kwargs=url_args) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('releases.html') origin_branches = origin_snapshot[0] diff --git a/swh/web/tests/browse/views/test_person.py b/swh/web/tests/browse/views/test_person.py --- a/swh/web/tests/browse/views/test_person.py +++ b/swh/web/tests/browse/views/test_person.py @@ -28,7 +28,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/person.html') self.assertContains(resp, '
%s
' % test_person_data['id']) self.assertContains(resp, '
%s
' % test_person_data['name']) @@ -47,6 +47,6 @@ url = reverse('browse-person', kwargs={'person_id': 457587}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Person not found', status_code=404) diff --git a/swh/web/tests/browse/views/test_release.py b/swh/web/tests/browse/views/test_release.py --- a/swh/web/tests/browse/views/test_release.py +++ b/swh/web/tests/browse/views/test_release.py @@ -49,7 +49,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/release.html') self.assertContains(resp, '%s' % (author_url, author_name)) @@ -84,7 +84,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/release.html') self.assertContains(resp, author_url) @@ -106,6 +106,6 @@ url = reverse('browse-release', kwargs={'sha1_git': 'ffff'}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Release not found', status_code=404) diff --git a/swh/web/tests/browse/views/test_revision.py b/swh/web/tests/browse/views/test_revision.py --- a/swh/web/tests/browse/views/test_revision.py +++ b/swh/web/tests/browse/views/test_revision.py @@ -53,7 +53,7 @@ resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/revision.html') self.assertContains(resp, '%s' % (author_url, author_name)) @@ -151,7 +151,7 @@ query_params={'revs_breadcrumb': revision_id_test, 'per_page': per_page}) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/revision-log.html') self.assertContains(resp, '', count=per_page) @@ -186,7 +186,7 @@ query_params={'revs_breadcrumb': revision_id_test + '/' + prev_rev, 'per_page': per_page}) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/revision-log.html') self.assertContains(resp, '', count=per_page) @@ -210,7 +210,7 @@ query_params={'revs_breadcrumb': revision_id_test + '/' + prev_rev + '/' + prev_prev_rev, 'per_page': per_page}) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/revision-log.html') self.assertContains(resp, '', count=per_page) @@ -229,7 +229,7 @@ query_params={'revs_breadcrumb': revision_id_test + '/' + prev_rev, 'per_page': per_page}) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTemplateUsed('browse/revision-log.html') self.assertContains(resp, '', count=per_page//2) @@ -245,7 +245,7 @@ url = reverse('browse-revision', kwargs={'sha1_git': revision_id_test}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Revision not found', status_code=404) @@ -254,7 +254,7 @@ url = reverse('browse-revision-log', kwargs={'sha1_git': revision_id_test}) resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Revision not found', status_code=404) @@ -268,6 +268,6 @@ NotFoundExc('Origin not found') resp = self.client.get(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) self.assertTemplateUsed('error.html') self.assertContains(resp, 'Origin not found', status_code=404) diff --git a/swh/web/tests/common/test_converters.py b/swh/web/tests/common/test_converters.py --- a/swh/web/tests/common/test_converters.py +++ b/swh/web/tests/common/test_converters.py @@ -15,16 +15,16 @@ class ConvertersTestCase(SWHWebTestCase): def test_fmap(self): - self.assertEquals([2, 3, None, 4], - converters.fmap(lambda x: x+1, [1, 2, None, 3])) - self.assertEquals([11, 12, 13], - list(converters.fmap(lambda x: x+10, - map(lambda x: x, [1, 2, 3])))) - self.assertEquals({'a': 2, 'b': 4}, - converters.fmap(lambda x: x*2, {'a': 1, 'b': 2})) - self.assertEquals(100, - converters.fmap(lambda x: x*10, 10)) - self.assertEquals({'a': [2, 6], 'b': 4}, + self.assertEqual([2, 3, None, 4], + converters.fmap(lambda x: x+1, [1, 2, None, 3])) + self.assertEqual([11, 12, 13], + list(converters.fmap(lambda x: x+10, + map(lambda x: x, [1, 2, 3])))) + self.assertEqual({'a': 2, 'b': 4}, + converters.fmap(lambda x: x*2, {'a': 1, 'b': 2})) + self.assertEqual(100, + converters.fmap(lambda x: x*10, 10)) + self.assertEqual({'a': [2, 6], 'b': 4}, converters.fmap(lambda x: x*2, {'a': [1, 3], 'b': 2})) # noqa self.assertIsNone(converters.fmap(lambda x: x, None)) @@ -110,7 +110,7 @@ convert={'p', 'q', 'w'}, convert_fn=converters.convert_revision_metadata) - self.assertEquals(expected_output, actual_output) + self.assertEqual(expected_output, actual_output) def test_from_swh_edge_cases_do_no_conversion_if_none_or_not_bytes(self): some_input = { @@ -134,7 +134,7 @@ bytess={'c', 'd'}, dates={'e'}) - self.assertEquals(expected_output, actual_output) + self.assertEqual(expected_output, actual_output) def test_from_swh_edge_cases_convert_invalid_utf8_bytes(self): some_input = { @@ -164,7 +164,7 @@ def test_from_swh_empty(self): # when - self.assertEquals({}, converters.from_swh({})) + self.assertEqual({}, converters.from_swh({})) def test_from_swh_none(self): # when diff --git a/swh/web/tests/common/test_highlightjs.py b/swh/web/tests/common/test_highlightjs.py --- a/swh/web/tests/common/test_highlightjs.py +++ b/swh/web/tests/common/test_highlightjs.py @@ -13,114 +13,114 @@ def test_get_hljs_language_from_mime_type(self): lang = highlightjs.get_hljs_language_from_mime_type('text/plain') - self.assertEquals(lang, None) + self.assertEqual(lang, None) lang = highlightjs.get_hljs_language_from_mime_type('text/x-c') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_mime_type('text/x-c++') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_mime_type('text/x-perl') - self.assertEquals(lang, 'perl') + self.assertEqual(lang, 'perl') lang = highlightjs.get_hljs_language_from_mime_type('text/x-python') - self.assertEquals(lang, 'python') + self.assertEqual(lang, 'python') lang = highlightjs.get_hljs_language_from_mime_type('text/x-msdos-batch') # noqa - self.assertEquals(lang, 'dos') + self.assertEqual(lang, 'dos') lang = highlightjs.get_hljs_language_from_mime_type('text/x-tex') - self.assertEquals(lang, 'tex') + self.assertEqual(lang, 'tex') lang = highlightjs.get_hljs_language_from_mime_type('text/x-lisp') - self.assertEquals(lang, 'lisp') + self.assertEqual(lang, 'lisp') lang = highlightjs.get_hljs_language_from_mime_type('text/x-java') - self.assertEquals(lang, 'java') + self.assertEqual(lang, 'java') lang = highlightjs.get_hljs_language_from_mime_type('text/x-makefile') - self.assertEquals(lang, 'makefile') + self.assertEqual(lang, 'makefile') lang = highlightjs.get_hljs_language_from_mime_type('text/x-shellscript') # noqa - self.assertEquals(lang, 'bash') + self.assertEqual(lang, 'bash') lang = highlightjs.get_hljs_language_from_mime_type('image/png') - self.assertEquals(lang, None) + self.assertEqual(lang, None) def test_get_hljs_language_from_filename(self): lang = highlightjs.get_hljs_language_from_filename('foo') - self.assertEquals(lang, None) + self.assertEqual(lang, None) lang = highlightjs.get_hljs_language_from_filename('foo.h') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_filename('foo.c') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_filename('foo.c.in') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_filename('foo.cpp') - self.assertEquals(lang, 'cpp') + self.assertEqual(lang, 'cpp') lang = highlightjs.get_hljs_language_from_filename('foo.pl') - self.assertEquals(lang, 'perl') + self.assertEqual(lang, 'perl') lang = highlightjs.get_hljs_language_from_filename('foo.py') - self.assertEquals(lang, 'python') + self.assertEqual(lang, 'python') lang = highlightjs.get_hljs_language_from_filename('foo.md') - self.assertEquals(lang, 'markdown') + self.assertEqual(lang, 'markdown') lang = highlightjs.get_hljs_language_from_filename('foo.js') - self.assertEquals(lang, 'javascript') + self.assertEqual(lang, 'javascript') lang = highlightjs.get_hljs_language_from_filename('foo.bat') - self.assertEquals(lang, 'dos') + self.assertEqual(lang, 'dos') lang = highlightjs.get_hljs_language_from_filename('foo.json') - self.assertEquals(lang, 'json') + self.assertEqual(lang, 'json') lang = highlightjs.get_hljs_language_from_filename('foo.yml') - self.assertEquals(lang, 'yaml') + self.assertEqual(lang, 'yaml') lang = highlightjs.get_hljs_language_from_filename('foo.ini') - self.assertEquals(lang, 'ini') + self.assertEqual(lang, 'ini') lang = highlightjs.get_hljs_language_from_filename('foo.cfg') - self.assertEquals(lang, 'ini') + self.assertEqual(lang, 'ini') lang = highlightjs.get_hljs_language_from_filename('foo.hy') - self.assertEquals(lang, 'hy') + self.assertEqual(lang, 'hy') lang = highlightjs.get_hljs_language_from_filename('foo.lisp') - self.assertEquals(lang, 'lisp') + self.assertEqual(lang, 'lisp') lang = highlightjs.get_hljs_language_from_filename('foo.java') - self.assertEquals(lang, 'java') + self.assertEqual(lang, 'java') lang = highlightjs.get_hljs_language_from_filename('foo.sh') - self.assertEquals(lang, 'bash') + self.assertEqual(lang, 'bash') lang = highlightjs.get_hljs_language_from_filename('foo.cmake') - self.assertEquals(lang, 'cmake') + self.assertEqual(lang, 'cmake') lang = highlightjs.get_hljs_language_from_filename('foo.ml') - self.assertEquals(lang, 'ocaml') + self.assertEqual(lang, 'ocaml') lang = highlightjs.get_hljs_language_from_filename('foo.mli') - self.assertEquals(lang, 'ocaml') + self.assertEqual(lang, 'ocaml') lang = highlightjs.get_hljs_language_from_filename('foo.rb') - self.assertEquals(lang, 'ruby') + self.assertEqual(lang, 'ruby') lang = highlightjs.get_hljs_language_from_filename('foo.jl') - self.assertEquals(lang, 'julia') + self.assertEqual(lang, 'julia') lang = highlightjs.get_hljs_language_from_filename('Makefile') - self.assertEquals(lang, 'makefile') + self.assertEqual(lang, 'makefile') lang = highlightjs.get_hljs_language_from_filename('CMakeLists.txt') - self.assertEquals(lang, 'cmake') + self.assertEqual(lang, 'cmake') diff --git a/swh/web/tests/common/test_query.py b/swh/web/tests/common/test_query.py --- a/swh/web/tests/common/test_query.py +++ b/swh/web/tests/common/test_query.py @@ -20,13 +20,13 @@ def test_parse_hash_guess_sha1(self): h = 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15' r = query.parse_hash(h) - self.assertEquals(r, ('sha1', hashutil.hash_to_bytes(h))) + self.assertEqual(r, ('sha1', hashutil.hash_to_bytes(h))) def test_parse_hash_guess_sha256(self): h = '084C799CD551DD1D8D5C5F9A5D593B2' \ 'E931F5E36122ee5c793c1d08a19839cc0' r = query.parse_hash(h) - self.assertEquals(r, ('sha256', hashutil.hash_to_bytes(h))) + self.assertEqual(r, ('sha256', hashutil.hash_to_bytes(h))) def test_parse_hash_guess_algo_malformed_hash(self): with self.assertRaises(BadInputExc): @@ -35,17 +35,17 @@ def test_parse_hash_check_sha1(self): h = 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15' r = query.parse_hash('sha1:' + h) - self.assertEquals(r, ('sha1', hashutil.hash_to_bytes(h))) + self.assertEqual(r, ('sha1', hashutil.hash_to_bytes(h))) def test_parse_hash_check_sha1_git(self): h = 'e1d2d2f924e986ac86fdf7b36c94bcdf32beec15' r = query.parse_hash('sha1_git:' + h) - self.assertEquals(r, ('sha1_git', hashutil.hash_to_bytes(h))) + self.assertEqual(r, ('sha1_git', hashutil.hash_to_bytes(h))) def test_parse_hash_check_sha256(self): h = '084C799CD551DD1D8D5C5F9A5D593B2E931F5E36122ee5c793c1d08a19839cc0' r = query.parse_hash('sha256:' + h) - self.assertEquals(r, ('sha256', hashutil.hash_to_bytes(h))) + self.assertEqual(r, ('sha256', hashutil.hash_to_bytes(h))) def test_parse_hash_check_algo_malformed_sha1_hash(self): with self.assertRaises(BadInputExc): @@ -104,8 +104,8 @@ ['sha256', 'sha1_git'], 'useless error message for this use case') - self.assertEquals(algo, 'sha256') - self.assertEquals(sha, b'123') + self.assertEqual(algo, 'sha256') + self.assertEqual(sha, b'123') mock_hash.assert_called_once_with('sha256:123') @@ -114,7 +114,7 @@ actual_uuid = query.parse_uuid4('7c33636b-8f11-4bda-89d9-ba8b76a42cec') # then - self.assertEquals(actual_uuid, '7c33636b-8f11-4bda-89d9-ba8b76a42cec') + self.assertEqual(actual_uuid, '7c33636b-8f11-4bda-89d9-ba8b76a42cec') def test_parse_uuid4_ko(self): # when diff --git a/swh/web/tests/common/test_service.py b/swh/web/tests/common/test_service.py --- a/swh/web/tests/common/test_service.py +++ b/swh/web/tests/common/test_service.py @@ -127,7 +127,7 @@ 'sha1': '745bab676c8f3cec8016e0c39ea61cf57e518865'}]) # then - self.assertEquals(actual_lookup, [ + self.assertEqual(actual_lookup, [ {'filename': 'a', 'sha1': '456caf10e9535160d90e874b45aa426de762f19f', 'found': True}, @@ -151,7 +151,7 @@ 'sha1': '745bab676c8f3cec8016e0c39ea61cf57e518865'}]) # then - self.assertEquals(actual_lookup, [ + self.assertEqual(actual_lookup, [ {'filename': 'a', 'sha1': '456caf10e9535160d90e874b45aa426de762f19f', 'found': False}, @@ -170,8 +170,8 @@ 'sha1_git:123caf10e9535160d90e874b45aa426de762f19f') # then - self.assertEquals({'found': None, - 'algo': 'sha1_git'}, actual_lookup) + self.assertEqual({'found': None, + 'algo': 'sha1_git'}, actual_lookup) # check the function has been called with parameters mock_storage.content_find.assert_called_with( @@ -192,8 +192,8 @@ 'sha1:456caf10e9535160d90e874b45aa426de762f19f') # then - self.assertEquals({'found': stub_content, - 'algo': 'sha1'}, actual_lookup) + self.assertEqual({'found': stub_content, + 'algo': 'sha1'}, actual_lookup) mock_storage.content_find.assert_called_with( {'sha1': @@ -210,7 +210,7 @@ 'sha1_git:123caf10e9535160d90e874b45aa426de762f19f') # then - self.assertEquals({'found': False}, actual_lookup) + self.assertEqual({'found': False}, actual_lookup) # check the function has been called with parameters mock_storage.content_find.assert_called_with( @@ -231,7 +231,7 @@ 'sha1:456caf10e9535160d90e874b45aa426de762f19f') # then - self.assertEquals({'found': True}, actual_lookup) + self.assertEqual({'found': True}, actual_lookup) mock_storage.content_find.assert_called_with( {'sha1': @@ -908,7 +908,7 @@ sha1_git) # then - self.assertEquals(actual_revision, { + self.assertEqual(actual_revision, { 'id': hash_to_hex(sha1_git_bin), 'parents': [], 'children': [hash_to_hex(b'999'), hash_to_hex(b'777')], @@ -980,7 +980,7 @@ sha1_git) # then - self.assertEquals(actual_revision, { + self.assertEqual(actual_revision, { 'id': hash_to_hex(sha1_git_bin), 'parents': [], 'children': [hash_to_hex(b'999'), hash_to_hex(b'777')], @@ -1332,7 +1332,7 @@ self.SHA1_SAMPLE) # then - self.assertEquals(rv, {'message': self.SAMPLE_MESSAGE_BIN}) + self.assertEqual(rv, {'message': self.SAMPLE_MESSAGE_BIN}) mock_storage.revision_get.assert_called_with( [self.SHA1_SAMPLE_BIN]) @@ -1516,7 +1516,7 @@ res = service.lookup_revision_log_by( 1, 'refs/heads/master', None, limit=100) # then - self.assertEquals(res, None) + self.assertEqual(res, None) mock_storage.revision_log_by.assert_called_with( 1, 'refs/heads/master', None, limit=100) @@ -1549,7 +1549,7 @@ 'sha256:%s' % self.SHA256_SAMPLE) # then - self.assertEquals(actual_content, {'data': b'binary data'}) + self.assertEqual(actual_content, {'data': b'binary data'}) mock_storage.content_find.assert_called_once_with( {'sha256': self.SHA256_SAMPLE_BIN}) @@ -1750,7 +1750,7 @@ actual_revision = service.lookup_revision_by(10, 'master2', 'some-ts') # then - self.assertEquals(actual_revision, expected_rev) + self.assertEqual(actual_revision, expected_rev) mock_storage.revision_get_by.assert_called_with(10, 'master2', limit=1, @@ -1771,7 +1771,7 @@ actual_revision = service.lookup_revision_by(10, 'master2', 'some-ts') # then - self.assertEquals(actual_revision, expected_rev) + self.assertEqual(actual_revision, expected_rev) mock_storage.revision_get_by.assert_called_with(10, 'master2', limit=1, @@ -1799,7 +1799,7 @@ actual_revision = service.lookup_revision_by(10, 'master2', 'some-ts') # then - self.assertEquals(actual_revision, expected_rev) + self.assertEqual(actual_revision, expected_rev) mock_storage.revision_get_by.assert_called_with(10, 'master2', limit=1, @@ -1847,8 +1847,8 @@ origin_id, branch_name, ts, sha1_git) # then - self.assertEquals(actual_root_rev, stub_root_rev) - self.assertEquals(actual_rev, stub_rev) + self.assertEqual(actual_root_rev, stub_root_rev) + self.assertEqual(actual_rev, stub_rev) mock_storage.revision_get_by.assert_called_once_with( origin_id, branch_name, limit=1, timestamp=ts) @@ -1869,7 +1869,7 @@ actual_entities = list(service.lookup_entity_by_uuid(uuid_test)) # then - self.assertEquals(actual_entities, stub_entities) + self.assertEqual(actual_entities, stub_entities) mock_query.parse_uuid4.assert_called_once_with(uuid_test) mock_storage.entity_get.assert_called_once_with(uuid_test) @@ -1896,7 +1896,7 @@ }, limit=1000) # then - self.assertEquals(actual_revision, stub_rev) + self.assertEqual(actual_revision, stub_rev) mock_lookup.assert_called_once_with( 1, 'master', None, 'sha1-git', 1000) @@ -1915,7 +1915,7 @@ }, limit=10) # then - self.assertEquals(actual_revision, stub_rev) + self.assertEqual(actual_revision, stub_rev) mock_lookup.assert_called_once_with( 2, 'master2', 'some-ts') @@ -1933,7 +1933,7 @@ }) # then - self.assertEquals(actual_revision, stub_rev) + self.assertEqual(actual_revision, stub_rev) mock_lookup.assert_called_once_with( 'some-sha1-root', 'some-sha1', 100) @@ -1950,7 +1950,7 @@ }) # then - self.assertEquals(actual_revision, stub_rev) + self.assertEqual(actual_revision, stub_rev) mock_lookup.assert_called_once_with( 'some-sha1') @@ -1981,9 +1981,9 @@ rev_id, dir_result = service.lookup_directory_through_revision( {'id': 'rev'}, 'some/path', 100) # then - self.assertEquals(rev_id, 'rev-id') - self.assertEquals(dir_result, {'type': 'dir', - 'content': []}) + self.assertEqual(rev_id, 'rev-id') + self.assertEqual(dir_result, {'type': 'dir', + 'content': []}) mock_lookup_rev.assert_called_once_with({'id': 'rev'}, 100) mock_lookup_dir.assert_called_once_with('rev-id', 'some/path', False) @@ -2004,8 +2004,8 @@ rev_id, dir_result = service.lookup_directory_through_revision( {'id': 'rev'}, 'some/path', 10, with_data=True) # then - self.assertEquals(rev_id, 'rev-id') - self.assertEquals(dir_result, stub_result) + self.assertEqual(rev_id, 'rev-id') + self.assertEqual(dir_result, stub_result) mock_lookup_rev.assert_called_once_with({'id': 'rev'}, 10) mock_lookup_dir.assert_called_once_with('rev-id', 'some/path', True) diff --git a/swh/web/tests/common/test_templatetags.py b/swh/web/tests/common/test_templatetags.py --- a/swh/web/tests/common/test_templatetags.py +++ b/swh/web/tests/common/test_templatetags.py @@ -14,16 +14,16 @@ content = '{"url": "/api/1/abc/"}' expected_content = ('{"url": "/api/1/abc/"}') - self.assertEquals(swh_templatetags.urlize_links_and_mails(content), - expected_content) + self.assertEqual(swh_templatetags.urlize_links_and_mails(content), + expected_content) def test_urlize_api_links_browse(self): # update /browse link with html links content with links content = '{"url": "/browse/def/"}' expected_content = ('{"url": "' '/browse/def/"}') - self.assertEquals(swh_templatetags.urlize_links_and_mails(content), - expected_content) + self.assertEqual(swh_templatetags.urlize_links_and_mails(content), + expected_content) def test_urlize_header_links(self): # update api link with html links content with links @@ -34,8 +34,8 @@ </api/1/def/>; rel="prev" """ - self.assertEquals(swh_templatetags.urlize_header_links(content), - expected_content) + self.assertEqual(swh_templatetags.urlize_header_links(content), + expected_content) def test_safe_docstring_display(self): # update api link with html links content with links @@ -56,5 +56,5 @@

Here is something that is not part of the list

""" - self.assertEquals(swh_templatetags.safe_docstring_display(docstring), - expected_docstring) + self.assertEqual(swh_templatetags.safe_docstring_display(docstring), + expected_docstring) diff --git a/swh/web/tests/common/test_utils.py b/swh/web/tests/common/test_utils.py --- a/swh/web/tests/common/test_utils.py +++ b/swh/web/tests/common/test_utils.py @@ -80,7 +80,7 @@ ] for ts, exp_date in zip(input_timestamps, output_dates): - self.assertEquals(utils.parse_timestamp(ts), exp_date) + self.assertEqual(utils.parse_timestamp(ts), exp_date) def test_format_utc_iso_date(self): self.assertEqual(utils.format_utc_iso_date('2017-05-04T13:27:13+02:00'), # noqa @@ -95,11 +95,11 @@ {'name': 'swh-web', 'path': 'home/user/swh-environment/swh-web'} ] path_info = utils.gen_path_info(input_path) - self.assertEquals(path_info, expected_result) + self.assertEqual(path_info, expected_result) input_path = 'home/user/swh-environment/swh-web' path_info = utils.gen_path_info(input_path) - self.assertEquals(path_info, expected_result) + self.assertEqual(path_info, expected_result) @patch('swh.web.common.utils.service') def test_get_origin_visits(self, mock_service): diff --git a/swh/web/tests/conftest.py b/swh/web/tests/conftest.py new file mode 100644 --- /dev/null +++ b/swh/web/tests/conftest.py @@ -0,0 +1,40 @@ +# Copyright (C) 2018 The Software Heritage developers +# See the AUTHORS file at the top-level directory of this distribution +# License: GNU Affero General Public License version 3, or any later version +# See top-level LICENSE file for more information + +import json +import os + + +def pytest_configure(config): + # Small hack in order to be able to run the unit tests + # without static assets generated by webpack. + # Those assets are not really needed for the Python tests + # but the django templates will fail to load due to missing + # generated file webpack-stats.json describing the js and css + # files to include. + # So generate a dummy webpack-stats.json file to overcome + # that issue. + test_dir = os.path.dirname(__file__) + static_dir = os.path.join(test_dir, '../static') + webpack_stats = os.path.join(static_dir, 'webpack-stats.json') + if os.path.exists(webpack_stats): + return + bundles_dir = os.path.join(test_dir, '../assets/src/bundles') + _, dirs, _ = next(os.walk(bundles_dir)) + mock_webpack_stats = { + 'status': 'done', + 'publicPath': '/static', + 'chunks': {} + } + for bundle in dirs: + asset = 'js/%s.js' % bundle + mock_webpack_stats['chunks'][bundle] = [{ + 'name': asset, + 'publicPath': '/static/%s' % asset, + 'path': os.path.join(static_dir, asset) + }] + + with open(webpack_stats, 'w') as outfile: + json.dump(mock_webpack_stats, outfile) diff --git a/tox.ini b/tox.ini new file mode 100644 --- /dev/null +++ b/tox.ini @@ -0,0 +1,18 @@ +[tox] +envlist=flake8,py3 + +[testenv:py3] +deps = + .[testing] + pytest-cov + pytest-django +commands = + pytest --cov {envsitepackagesdir}/swh/web --cov-branch {posargs} {envsitepackagesdir}/swh/web + +[testenv:flake8] +skip_install = true +deps = + flake8 +commands = + {envpython} -m flake8 \ + --exclude=.tox,.git,__pycache__,.eggs,*.egg,node_modules