Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic functional test for DeepLinking launches #6918

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Dec 13, 2024

Add a basic functional test for the LTI1.1 deep linking launch.

This is similar to the existing basic LTI launch test so there's some fixtures that are moved around and refactored to be able to reuse them in both cases.

This only cover the launch side of DeepLinking and the intention is just to have a sanity check type of test. In a follow up PR I'll add test for the API side of deep linking.

@marcospri marcospri force-pushed the deep-link-functest branch 4 times, most recently from de6303c to dc7db58 Compare December 13, 2024 10:32
@@ -84,13 +83,6 @@ def test_basic_lti_launch_canvas_deep_linking_canvas_file(
== 1
)

@pytest.fixture(autouse=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to conftest.py

@@ -104,12 +96,6 @@ def assignment(self, db_session, application_instance, lti_params):

return assignment

@pytest.fixture
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, moved to conftest.py

},
**kwargs,
)
return functools.partial(_lti_v11_launch, app, "/lti_launches")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this fixture a bit to be able to reuse it for deep linking launches.



@pytest.fixture
def application_instance(db_session): # noqa: ARG001
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common fixtures between basic launch and deep linking launch moved here.

@@ -25,6 +29,14 @@
)


@pytest.fixture
def environ():
environ = dict(os.environ)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixture to make easier to access the os.environ version that contains all TEST_ENVIROMENT values.

@@ -23,33 +21,35 @@ def test_requests_with_no_oauth_signature_are_forbidden(
assert response.headers["Content-Type"] == Any.string.matching("^text/html")
assert response.html

def test_unconfigured_basic_lti_launch(self, lti_params, do_lti_launch):
def test_unconfigured_basic_lti_launch(
self, lti_params, do_lti_launch, get_client_config
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes to accommodate get_client_config being now a fixture instead of a local function.

get_client_config,
environ,
):
response = do_deep_link_launch(post_params=lti_params, status=200)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very simple test, similar to the basic launch ones.

Make a request, assert the contents of the response's config.

@@ -26,6 +26,7 @@
"h_api_url_private": "https://h.example.com/private/api/",
"rpc_allowed_origins": ["http://localhost:5000"],
"oauth2_state_secret": "test_oauth2_state_secret",
"onedrive_client_id": "test_one_drive_client_id",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing setting on the tests fixture.

@marcospri marcospri requested a review from mtomilov December 13, 2024 10:48
Base automatically changed from rename-test to main December 16, 2024 08:31
@mtomilov
Copy link

LGTM 👍

Just covering the LTI1.1 version on this commit.
@marcospri marcospri merged commit b2a92df into main Dec 16, 2024
9 checks passed
@marcospri marcospri deleted the deep-link-functest branch December 16, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants