Beispiel #1
0
    def test_execute_statement_parsing_error(self):
        statement = {}

        eh_api.execute_statement(statement)

        self.assertEqual(1, FailedStatement.objects.count())
        self.assertEqual('Parsing error',
                         FailedStatement.objects.all().first().error)
Beispiel #2
0
    def test_execute_statement_value_error(self, a, b):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://id.tincanapi.com/activitytype/lms/course'
                }
            }
        }

        eh_api.execute_statement(statement)

        self.assertEqual(0, FailedStatement.objects.count())
        a.assert_not_called()
Beispiel #3
0
    def test_execute_statement_unknown_error(self, a):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://id.tincanapi.com/activitytype/chapter'
                }
            }
        }

        eh_api.execute_statement(statement)

        self.assertEqual(1, FailedStatement.objects.count())
        self.assertEqual('Unexpected error: <class \'Exception\'>',
                         FailedStatement.objects.all().first().error)
Beispiel #4
0
    def test_execute_statement_missing_assistant(self, a):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://id.tincanapi.com/activitytype/lms/module'
                }
            }
        }

        eh_api.execute_statement(statement)

        self.assertEqual(1, FailedStatement.objects.count())
        self.assertEqual('Missing assistant or Course item',
                         FailedStatement.objects.all().first().error)
Beispiel #5
0
    def test_execute_statement_unknown_type(self):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://id.tincanapi.com/activitytype/lms/unknown'
                }
            }
        }

        eh_api.execute_statement(statement)

        self.assertEqual(1, FailedStatement.objects.count())
        self.assertEqual('Unknown type',
                         FailedStatement.objects.all().first().error)
Beispiel #6
0
    def test_execute_statement_connection_error(self, a, b):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://activitystrea.ms/schema/1.0/page'
                }
            }
        }

        eh_api.execute_statement(statement)

        self.assertEqual(1, FailedStatement.objects.count())
        self.assertEqual('Mofa connection failure',
                         FailedStatement.objects.all().first().error)
Beispiel #7
0
    def test_execute_statement_role_changed(self, a, b):
        statement = {
            'id': 'dummy-statement-id',
            'object': {
                'definition': {
                    'type': 'http://id.tincanapi.com/activitytype/role/teacher'
                }
            }
        }

        eh_api.execute_statement(statement)

        a.assert_called_with(
            'http://localhost:1234/assistants/api/user_sync_agent/',
            headers={'Content-Type': 'application/json'},
            json={'statement': statement})
Beispiel #8
0
    def test_execute_statement_quiz_completed(self, a, b):
        statement = {
            'id': 'dummy-statement-id',
            'verb': {
                'id': 'http://adlnet.gov/expapi/verbs/completed'
            },
            'object': {
                'id': 'http://localhost:4000/mod/quiz/view.php?id=3',
                'definition': {
                    'type': 'http://adlnet.gov/expapi/activities/assessment'
                }
            }
        }

        eh_api.execute_statement(statement)

        a.assert_called_with(
            'http://localhost:1234/assistants/api/new_activity_notification/1',
            headers={'Content-Type': 'application/json'},
            json={'statement': statement})