-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: implement test suite for superset integration
- Loading branch information
Showing
10 changed files
with
230 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Tests for the filters module. | ||
""" | ||
|
||
from unittest import TestCase | ||
from unittest.mock import Mock, patch | ||
|
||
from aspects.extensions.filters import BLOCK_CATEGORY, AddSupersetTab | ||
|
||
|
||
class TestFilters(TestCase): | ||
""" | ||
Test suite for the LimeSurveyXBlock filters. | ||
""" | ||
|
||
def setUp(self) -> None: | ||
""" | ||
Set up the test suite. | ||
""" | ||
self.filter = AddSupersetTab(filter_type=Mock(), running_pipeline=Mock()) | ||
self.template_name = "test-template-name" | ||
self.context = {"course": Mock()} | ||
|
||
@patch("aspects.extensions.filters.generate_superset_context") | ||
def test_run_filter(self, mock_generate_superset_context): | ||
""" | ||
Check the filter is not executed when there are no LimeSurvey blocks in the course. | ||
Expected result: | ||
- The context is returned without modifications. | ||
""" | ||
mock_generate_superset_context.return_value = { | ||
"sections": [], | ||
} | ||
|
||
context = self.filter.run_filter(self.context, self.template_name) | ||
|
||
self.assertDictContainsSubset( | ||
{ | ||
"course_id": str(self.context["course"].id), | ||
"section_key": BLOCK_CATEGORY, | ||
"section_display_name": BLOCK_CATEGORY.title(), | ||
"template_path_prefix": "/instructor_dashboard/", | ||
}, | ||
context["context"]["sections"][0], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Test plugin settings for commond, devstack and production environments | ||
""" | ||
|
||
from django.conf import settings | ||
from django.test import TestCase | ||
|
||
from aspects.settings import common as common_settings | ||
from aspects.settings import production as production_setttings | ||
|
||
|
||
class TestPluginSettings(TestCase): | ||
""" | ||
Tests plugin settings | ||
""" | ||
|
||
def test_common_settings(self): | ||
""" | ||
Test common settings | ||
""" | ||
settings.MAKO_TEMPLATE_DIRS_BASE = [] | ||
common_settings.plugin_settings(settings) | ||
self.assertIn("MAKO_TEMPLATE_DIRS_BASE", settings.__dict__) | ||
self.assertIn("url", settings.SUPERSET_CONFIG) | ||
self.assertIn("username", settings.SUPERSET_CONFIG) | ||
self.assertIn("password", settings.SUPERSET_CONFIG) | ||
self.assertIn("dashboard_slug", settings.SUPERSET_INSTRUCTOR_DASHBOARD) | ||
self.assertIn("dashboard_uuid", settings.SUPERSET_INSTRUCTOR_DASHBOARD) | ||
self.assertIsNotNone(settings.SUPERSET_EXTRA_FILTERS_FORMAT) | ||
|
||
def test_production_settings(self): | ||
""" | ||
Test production settings | ||
""" | ||
settings.ENV_TOKENS = { | ||
"SUPERSET_CONFIG": { | ||
"url": "http://superset.local.overhang.io:8088", | ||
"username": "superset", | ||
"password": "superset", | ||
}, | ||
"SUPERSET_INSTRUCTOR_DASHBOARD": { | ||
"dashboard_slug": "instructor-dashboard", | ||
"dashboard_uuid": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286", | ||
}, | ||
"SUPERSET_EXTRA_FILTERS_FORMAT": [], | ||
} | ||
production_setttings.plugin_settings(settings) | ||
self.assertEqual( | ||
settings.SUPERSET_CONFIG, settings.ENV_TOKENS["SUPERSET_CONFIG"] | ||
) | ||
self.assertEqual( | ||
settings.SUPERSET_INSTRUCTOR_DASHBOARD, | ||
settings.ENV_TOKENS["SUPERSET_INSTRUCTOR_DASHBOARD"], | ||
) | ||
self.assertEqual( | ||
settings.SUPERSET_EXTRA_FILTERS_FORMAT, | ||
settings.ENV_TOKENS["SUPERSET_EXTRA_FILTERS_FORMAT"], | ||
) |
Oops, something went wrong.