diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 392cabd..9788738 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -60,14 +60,21 @@ jobs: run: | python -Wd manage.py check python manage.py makemigrations --check --dry-run + - name: Run unit tests + working-directory: ./ror-api + run: | + python -Wa manage.py test rorapi.tests.tests_unit - name: Load test data working-directory: ./ror-api run: | python manage.py setup ${{ env.TEST_DATA_DUMP_FILE }} -t - - name: Run Tests + - name: Run integration tests working-directory: ./ror-api run: | - python -Wa manage.py test rorapi.tests.tests_unit - # TODO fix these tests running in GitHub Action - # python manage.py test rorapi.tests.tests_integration + python manage.py test rorapi.tests.tests_integration.tests_heartbeat + # HTTP suites assume a full public corpus (specific ROR IDs, >50k + # records). The CI test dump does not satisfy that, so they stay off. + # python manage.py test rorapi.tests.tests_integration.tests_v2 + # python manage.py test rorapi.tests.tests_integration.tests_search_v2 + # python manage.py test rorapi.tests.tests_integration.tests_matching_v2 # python manage.py test rorapi.tests.tests_functional diff --git a/rorapi/tests/tests_integration/tests.py b/rorapi/tests/tests_integration/tests.py index 7336414..2c8ec62 100644 --- a/rorapi/tests/tests_integration/tests.py +++ b/rorapi/tests/tests_integration/tests.py @@ -2,6 +2,8 @@ import json import os import re +import unittest + import requests from django.test import SimpleTestCase @@ -11,6 +13,10 @@ os.environ.get('ROR_BASE_URL', 'http://localhost')) +@unittest.skip( + 'Expects the removed v1 response shape (name, country.country_code). ' + 'v2 coverage is tests_v2.py.' +) class APITestCase(SimpleTestCase): def get_total(self, output): return output['number_of_results'] diff --git a/rorapi/tests/tests_integration/tests_heartbeat.py b/rorapi/tests/tests_integration/tests_heartbeat.py new file mode 100644 index 0000000..29869c5 --- /dev/null +++ b/rorapi/tests/tests_integration/tests_heartbeat.py @@ -0,0 +1,10 @@ +from django.test import SimpleTestCase + + +class HeartbeatViewTestCase(SimpleTestCase): + """Needs a live organizations-v2 index, so it runs with the integration suite.""" + + def test_heartbeat_success(self): + response = self.client.get('/heartbeat') + self.assertEqual(response.status_code, 200) + self.assertEqual(response.content, b'OK') diff --git a/rorapi/tests/tests_unit/tests_views_v2.py b/rorapi/tests/tests_unit/tests_views_v2.py index 5816532..e046f44 100644 --- a/rorapi/tests/tests_unit/tests_views_v2.py +++ b/rorapi/tests/tests_unit/tests_views_v2.py @@ -389,20 +389,6 @@ def test_index_ror_success_with_auth_headers(self, index_mock): ) self.assertEqual(response.status_code, 200) -class HeartbeatViewTestCase(SimpleTestCase): - def setUp(self): - with open( - os.path.join(os.path.dirname(__file__), - 'data/test_data_search_es7_v2.json'), 'r') as f: - self.test_data = json.load(f) - - @mock.patch('elasticsearch_dsl.Search.execute') - def test_heartbeat_success(self, search_mock): - search_mock.return_value = \ - IterableAttrDict(self.test_data, self.test_data['hits']['hits']) - response = self.client.get('/v2/heartbeat') - self.assertEqual(response.status_code, 200) - class BulkUpdateViewTestCase(SimpleTestCase): def setUp(self): self.csv_errors_empty = []