Esempio n. 1
0
 def test_ToJSON(self):
     substatement = SubStatement(object_type='SubStatement',
                                 actor=Agent(name='test'),
                                 verb=Verb(id='test'),
                                 object=Activity(id='test'))
     self.assertEqual(
         json.loads(substatement.to_json()),
         json.loads(
             '{"verb": {"id": "test"}, "object": {"id": "test", "objectType": "Activity"}, '
             '"actor": {"name": "test", "objectType": "Agent"}, "objectType": "SubStatement"}'
         ))
 def test_FromJSON(self):
     json_str = '{"object_type":"SubStatement", "actor":{"name":"test"}, "verb":{"id":"test"}, "object":{"id":"test"}}'
     substatement = SubStatement.from_json(json_str)
     self.assertEqual(substatement.object_type, 'SubStatement')
     self.agentVerificationHelper(substatement.actor)
     self.verbVerificationHelper(substatement.verb)
     self.activityVerificationHelper(substatement.object)
Esempio n. 3
0
 def test_InitAnonGroupActor(self):
     substatement = SubStatement(actor={
         'object_type': 'Group',
         'member': [{
             "name": "test"
         }]
     })
     self.groupVerificationHelper(substatement.actor)
 def test_FromJSON(self):
     json_str = '{"object_type":"SubStatement", "actor":{"name":"test"}, ' \
                '"verb":{"id":"test"}, "object":{"id":"test"}}'
     substatement = SubStatement.from_json(json_str)
     self.assertEqual(substatement.object_type, 'SubStatement')
     self.agentVerificationHelper(substatement.actor)
     self.verbVerificationHelper(substatement.verb)
     self.activityVerificationHelper(substatement.object)
 def test_InitUnpack(self):
     obj = {'object_type': 'SubStatement', 'actor': {'name': 'test'}, 'verb': {'id': 'test'},
            'object': {'id': 'test'}}
     substatement = SubStatement(**obj)
     self.assertEqual(substatement.object_type, 'SubStatement')
     self.agentVerificationHelper(substatement.actor)
     self.verbVerificationHelper(substatement.verb)
     self.activityVerificationHelper(substatement.object)
 def test_InitSubStatementObject(self):
     statement = Statement(object=SubStatement(object_type='SubStatement'))
     self.assertIsNone(statement.id)
     self.assertIsNone(statement.verb)
     self.assertIsNone(statement.actor)
     self.assertIsNone(statement.timestamp)
     self.assertIsNone(statement.stored)
     self.assertIsNone(statement.authority)
     self.substatementVerificationHelper(statement.object)
Esempio n. 7
0
    def setUp(self):
        self.endpoint = lrs_properties.endpoint
        self.version = lrs_properties.version
        self.username = lrs_properties.username
        self.password = lrs_properties.password
        self.lrs = RemoteLRS(
            version=self.version,
            endpoint=self.endpoint,
            username=self.username,
            password=self.password,
        )

        self.agent = Agent(mbox="mailto:[email protected]")
        self.agent2 = Agent(mbox="mailto:[email protected]")
        self.verb = Verb(id="http://adlnet.gov/expapi/verbs/experienced",
                         display=LanguageMap({"en-US": "experienced"}))

        self.group = Group(member=[self.agent, self.agent2])

        self.activity = Activity(
            id="http://tincanapi.com/TinCanPython/Test/Unit/0",
            definition=ActivityDefinition())
        self.activity.definition.type = "http://id.tincanapi.com/activitytype/unit-test"
        self.activity.definition.name = LanguageMap({"en-US": "Python Tests"})
        self.activity.definition.description = LanguageMap(
            {"en-US": "Unit test in the test suite for the Python library"})
        self.activity.object_type = 'Activity'

        self.parent = Activity(id="http://tincanapi.com/TinCanPython/Test",
                               definition=ActivityDefinition())
        self.parent.definition.type = "http://id.tincanapi.com/activitytype/unit-test-suite"
        self.parent.definition.name = LanguageMap({"en-US": "Python Tests"})
        self.parent.definition.description = LanguageMap(
            {"en-US": "Unit test in the test suite for the Python library"})
        self.parent.object_type = 'Activity'

        self.statement_ref = StatementRef(id=uuid.uuid4())

        self.context = Context(registration=uuid.uuid4(),
                               statement=self.statement_ref)
        # self.context.context_activities = ContextActivities(parent=[self.parent])

        self.score = Score(raw=97, scaled=0.97, max=100, min=0)

        self.result = Result(score=self.score,
                             success=True,
                             completion=True,
                             duration="PT120S")

        self.substatement = SubStatement(
            actor=self.agent,
            verb=self.verb,
            object=self.activity,
        )
 def test_FromJSONToJSON(self):
     json_str = '{"object_type":"SubStatement", "actor":{"name":"test"}, "verb":{"id":"test"}, "' \
                'object":{"id":"test", "objectType": "Activity"}}'
     substatement = SubStatement.from_json(json_str)
     self.assertEqual(substatement.object_type, 'SubStatement')
     self.agentVerificationHelper(substatement.actor)
     self.verbVerificationHelper(substatement.verb)
     self.activityVerificationHelper(substatement.object)
     self.assertEqual(json.loads(substatement.to_json()),
                      json.loads('{"verb": {"id": "test"}, "object": {"id": "test", "objectType": "Activity"}, '
                                 '"actor": {"name": "test", "objectType": "Agent"}, "objectType": "SubStatement"}'))
 def test_InitAnonObject(self):
     substatement = SubStatement(object={'id': 'test'})
     self.activityVerificationHelper(substatement.object)
 def test_InitActivityObject(self):
     substatement = SubStatement(object=Activity(id='test'))
     self.activityVerificationHelper(substatement.object)
 def test_InitGroupObject(self):
     substatement = SubStatement(object=Group(member=[Agent(name='test')]))
     self.groupVerificationHelper(substatement.object)
 def test_InitAgentObject(self):
     substatement = SubStatement(object=Agent(name='test'))
     self.agentVerificationHelper(substatement.object)
 def test_InitVerb(self):
     substatement = SubStatement(verb=Verb(id='test'))
     self.verbVerificationHelper(substatement.verb)
 def test_InitGroupActor(self):
     substatement = SubStatement(actor=Group(member=[Agent(name='test')]))
     self.groupVerificationHelper(substatement.actor)
 def test_InitAgentActor(self):
     substatement = SubStatement(actor=Agent(name='test'))
     self.agentVerificationHelper(substatement.actor)
 def test_InitObjectType(self):
     substatement = SubStatement(object_type="SubStatement")
     self.assertEqual(substatement.object_type, "SubStatement")
 def test_InitDifferentNamingObject(self):
     substatement = SubStatement(object={'objectType': 'Agent', 'name': 'test'})
     self.agentVerificationHelper(substatement.object)
Esempio n. 18
0
 def test_ToJSONEmpty(self):
     substatement = SubStatement()
     self.assertEqual(substatement.to_json(), '{"objectType": "SubStatement"}')
 def test_InitAnonVerb(self):
     substatement = SubStatement(verb={'id': 'test'})
     self.verbVerificationHelper(substatement.verb)
 def test_InitAnonAgentActor(self):
     substatement = SubStatement(actor={'object_type': 'Agent', 'name': 'test'})
     self.agentVerificationHelper(substatement.actor)
 def test_ToJSONEmpty(self):
     substatement = SubStatement()
     self.assertEqual(json.loads(substatement.to_json()), json.loads('{"objectType": "SubStatement"}'))
 def test_InitAnonAgentObject(self):
     substatement = SubStatement(object={'object_type': 'Agent', 'name': 'test'})
     self.agentVerificationHelper(substatement.object)
Esempio n. 23
0
 def test_ToJSON(self):
     substatement = SubStatement(object_type='SubStatement', actor=Agent(name='test'), verb=Verb(id='test'), object=Activity(id='test'))
     self.assertEqual(substatement.to_json(), '{"verb": {"id": "test"}, "object": {"id": "test", "objectType": "Activity"}, "actor": {"name": "test", "objectType": "Agent"}, "objectType": "SubStatement"}')