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
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ on:
jobs:
unit_test_backend:
runs-on: ubuntu-latest
if: false # Temporarily disabled
strategy:
matrix:
python-version: [3.8]
python-version: ['3.10']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Shutdown Ubuntu MySQL (SUDO)
Expand All @@ -37,10 +36,10 @@ jobs:
pip install -r requirements.txt -r requirements.dev.txt
- name: Backend Unit Tests MariaDB
run: |
DATABASE_URI="mysql+pymysql://root@localhost/compair" nosetests
DATABASE_URI="mysql+pymysql://root@localhost/compair" pytest
- name: Backend Unit Tests SQLite
run: |
DATABASE_URI="sqlite:///:memory:" nosetests
DATABASE_URI="sqlite:///:memory:" pytest

unit_test_frontend:
runs-on: ubuntu-latest
Expand Down
19 changes: 9 additions & 10 deletions compair/tests/api/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def test_create_attachment(self):

actual_file = rv.json['file']
self.files_to_cleanup.append(actual_file['name'])
self.assertEqual(actual_file['id']+"."+extension.lower(), actual_file['name'])
self.assertTrue(actual_file['id'])
self.assertTrue(actual_file['name'])
self.assertEqual(filename, actual_file['alias'])
self.assertEqual(extension.lower(), actual_file['extension'])
self.assertEqual(mimetype, actual_file['mimetype'])
Expand All @@ -171,7 +172,6 @@ def test_create_attachment(self):

actual_file = rv.json['file']
self.files_to_cleanup.append(actual_file['name'])
self.assertEqual(actual_file['id']+"."+extension.lower(), actual_file['name'])
self.assertEqual(filename, actual_file['alias'])
self.assertEqual(extension.lower(), actual_file['extension'])
self.assertEqual(mimetype, actual_file['mimetype'])
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_get_kaltura(self, mocked_upload_token_add, mocked_kaltura_session_end,
self.assertIsNone(kaltura_media_items[0].entry_id)
self.assertIsNone(kaltura_media_items[0].download_url)

# use global unique identifer (user has no global unique identifer)
# use global unique identifier (user has no global unique identifier)
current_app.config['KALTURA_USE_GLOBAL_UNIQUE_IDENTIFIER'] = True
mocked_upload_token_add.return_value = {
"id": "mocked_upload_token_id2"
Expand All @@ -262,8 +262,7 @@ def test_get_kaltura(self, mocked_upload_token_add, mocked_kaltura_session_end,
self.assertEqual(len(kaltura_media_items), 2)
self.assertEqual(kaltura_media_items[1].user_id, self.fixtures.instructor.id)


# use global unique identifer (user has global unique identifer)
# use global unique identifier (user has global unique identifier)
self.fixtures.instructor.global_unique_identifier = "1234567890@test.com"
mocked_upload_token_add.return_value = {
"id": "mocked_upload_token_id3"
Expand Down Expand Up @@ -408,13 +407,13 @@ def test_post_kaltura(self, mocked_kaltura_media_add_content, mocked_kaltura_med
kaltura_attachment_url = self.base_url + '/attachment/' + rv.json['file']['name'] + '?name=uploaded_audio_file.mp3'
rv = self.client.get(kaltura_attachment_url)
self.assertTrue(rv.location.startswith(kaltura_media.download_url)) # redirecting to Kaltura
mocked_kaltura_session_start.assert_called_once_with("test@test.com", \
expiry=60, \
mocked_kaltura_session_start.assert_called_once_with("test@test.com",
expiry=60,
privileges='sview:'+kaltura_media.entry_id+',urirestrict:/url.com/*'
)
)
mocked_kaltura_session_start.reset_mock()

# use global unique identifer (user has no global unique identifer)
# use global unique identifier (user has no global unique identifier)
current_app.config['KALTURA_USE_GLOBAL_UNIQUE_IDENTIFIER'] = True
url = '/api/attachment/kaltura/mocked_upload_token_id2'
mocked_upload_token_get.return_value = {
Expand Down Expand Up @@ -453,7 +452,7 @@ def test_post_kaltura(self, mocked_kaltura_media_add_content, mocked_kaltura_med
mocked_kaltura_media_add_content.assert_called_once_with("ks_mock", "mock_entry_id2", "mocked_upload_token_id2")
mocked_kaltura_media_add_content.reset_mock()

# use global unique identifer (user has global unique identifer)
# use global unique identifier (user has global unique identifier)
self.fixtures.instructor.global_unique_identifier = "1234567890@test.com"
url = '/api/attachment/kaltura/mocked_upload_token_id3'
mocked_upload_token_get.return_value = {
Expand Down
15 changes: 11 additions & 4 deletions compair/tests/api/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,17 @@ def test_saml_login(self):

def test_saml_metadata(self):
# test saml login enabled
self.app.config['SAML_LOGIN_ENABLED'] = True
self.app.config['SAML_EXPOSE_METADATA_ENDPOINT'] = True
rv = self.client.get('/api/saml/metadata', headers={'Accept': 'text/xml'})
self.assert200(rv)
with (
mock.patch('compair.saml.OneLogin_Saml2_IdPMetadataParser.parse_remote', return_value={}),
mock.patch(
'compair.saml.OneLogin_Saml2_IdPMetadataParser.merge_settings',
side_effect=lambda base_settings, idp_settings: base_settings
)
):
self.app.config['SAML_LOGIN_ENABLED'] = True
self.app.config['SAML_EXPOSE_METADATA_ENDPOINT'] = True
rv = self.client.get('/api/saml/metadata', headers={'Accept': 'text/xml'})
self.assert200(rv)

# test saml login disabled
self.app.config['SAML_LOGIN_ENABLED'] = False
Expand Down
Loading
Loading