Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions rorapi/tests/tests_integration/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import os
import re
import unittest

import requests

from django.test import SimpleTestCase
Expand All @@ -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']
Expand Down
10 changes: 10 additions & 0 deletions rorapi/tests/tests_integration/tests_heartbeat.py
Original file line number Diff line number Diff line change
@@ -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')
14 changes: 0 additions & 14 deletions rorapi/tests/tests_unit/tests_views_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
Loading