Beispiel #1
0
    def test_h_group_name_returns_group_names_based_on_context_titles(
            self, context_title, expected_group_name, lti_params_for,
            pyramid_request):
        lti_params_for.return_value = {"context_title": context_title}

        assert resources.LTILaunch(
            pyramid_request).h_group_name == expected_group_name
Beispiel #2
0
    def test_provisioning_enabled_raises_if_no_oauth_consumer_key_in_params(
            self, lti_params_for, pyramid_request):
        del lti_params_for.return_value["oauth_consumer_key"]
        lti_launch = resources.LTILaunch(pyramid_request)

        with pytest.raises(HTTPBadRequest):
            lti_launch.provisioning_enabled
Beispiel #3
0
    def test_h_provider_unique_id_raises_if_user_id_is_missing(
            self, request_params, lti_params_for, pyramid_request):
        lti_params_for.return_value = request_params

        with pytest.raises(
                HTTPBadRequest,
                match='Required parameter "user_id" missing from LTI params'):
            resources.LTILaunch(pyramid_request).h_provider_unique_id
Beispiel #4
0
    def test_h_provider_unique_id_just_returns_the_user_id(
            self, lti_params_for, pyramid_request):
        lti_params_for.return_value = {"user_id": "4533***70d9"}

        provider_unique_id = resources.LTILaunch(
            pyramid_request).h_provider_unique_id

        assert provider_unique_id == "4533***70d9"
Beispiel #5
0
    def test_h_userid(self, pyramid_request, lti_params_for):
        lti_params_for.return_value = {
            "tool_consumer_instance_guid": "VCSy*G1u3:canvas-lms",
            "user_id": "4533***70d9",
        }

        userid = resources.LTILaunch(pyramid_request).h_userid

        assert userid == "acct:2569ad7b99f316ecc7dfee5c0c801c@TEST_AUTHORITY"
Beispiel #6
0
    def test_h_provider_just_returns_the_tool_consumer_instance_guid(
            self, lti_params_for, pyramid_request):
        lti_params_for.return_value = {
            "tool_consumer_instance_guid": "VCSy*G1u3:canvas-lms"
        }

        provider = resources.LTILaunch(pyramid_request).h_provider

        assert provider == "VCSy*G1u3:canvas-lms"
Beispiel #7
0
 def test_h_groupid_raises_if_theres_no_tool_consumer_instance_guid(
         self, lti_params_for, pyramid_request):
     lti_params_for.return_value = {}
     with pytest.raises(
             HTTPBadRequest,
             match=
             'Required parameter "tool_consumer_instance_guid" missing from LTI params',
     ):
         resources.LTILaunch(pyramid_request).h_groupid
Beispiel #8
0
    def test_hypothesis_config_raises_if_theres_no_oauth_consumer_key(
            self, lti_params_for, pyramid_request):
        lti_params_for.return_value = {}

        with pytest.raises(
                HTTPBadRequest,
                match=
                'Required parameter "oauth_consumer_key" missing from LTI params',
        ):
            resources.LTILaunch(pyramid_request).hypothesis_config
Beispiel #9
0
    def test_h_userid_raises_if_user_id_is_missing(self, lti_params_for,
                                                   pyramid_request):
        lti_params_for.return_value = {
            "tool_consumer_instance_guid": "VCSy*G1u3:canvas-lms"
        }

        with pytest.raises(
                HTTPBadRequest,
                match='Required parameter "user_id" missing from LTI params'):
            resources.LTILaunch(pyramid_request).h_userid
Beispiel #10
0
    def test_h_username_raises_if_tool_consumer_instance_guid_is_missing(
            self, lti_params_for, pyramid_request):
        lti_params_for.return_value = {"user_id": "4533***70d9"}

        with pytest.raises(
                HTTPBadRequest,
                match=
                'Required parameter "tool_consumer_instance_guid" missing from LTI params',
        ):
            resources.LTILaunch(pyramid_request).h_username
Beispiel #11
0
    def test_h_provider_raises_if_tool_consumer_instance_guid_is_missing(
            self, request_params, lti_params_for, pyramid_request):
        lti_params_for.return_value = request_params

        with pytest.raises(
                HTTPBadRequest,
                match=
                'Required parameter "tool_consumer_instance_guid" missing from LTI params',
        ):
            resources.LTILaunch(pyramid_request).h_provider
Beispiel #12
0
    def test_h_username_returns_a_30_char_string(self, pyramid_request,
                                                 lti_params_for):
        lti_params_for.return_value = {
            "tool_consumer_instance_guid": "VCSy*G1u3:canvas-lms",
            "user_id": "4533***70d9",
        }

        username = resources.LTILaunch(pyramid_request).h_username

        assert isinstance(username, str)
        assert len(username) == 30
Beispiel #13
0
    def test_hypothesis_config_raises_if_theres_no_tool_consumer_instance_guid(
            self, lti_params_for, pyramid_request):
        lti_params_for.return_value = {
            "oauth_consumer_key": "Hypothesise3f14c1f7e8c89f73cefacdd1d80d0ef"
        }

        with pytest.raises(
                HTTPBadRequest,
                match=
                'Required parameter "tool_consumer_instance_guid" missing from LTI params',
        ):
            resources.LTILaunch(pyramid_request).hypothesis_config
Beispiel #14
0
 def lti_launch(self, pyramid_request):
     return resources.LTILaunch(pyramid_request)
Beispiel #15
0
    def test_h_display_name(self, request_params, expected_display_name,
                            lti_params_for, pyramid_request):
        lti_params_for.return_value = request_params

        assert (resources.LTILaunch(pyramid_request).h_display_name ==
                expected_display_name)
Beispiel #16
0
    def test_it_raises_if_no_lti_params_for_request(self, pyramid_request,
                                                    lti_params_for):
        lti_params_for.side_effect = HTTPBadRequest()

        with pytest.raises(HTTPBadRequest):
            resources.LTILaunch(pyramid_request)