Ejemplo n.º 1
0
    def handle(self, *args, **options):
        # make sure file option is present
        if options['extract_event_number'] is None:
            extract_event_number = 100
        else:
            extract_event_number = int(options['extract_event_number'])

        evt_list = TrackingLog.objects \
                              .filter(tincan_error='WRONG_VERB_OBJECT') \
                              .order_by('dtcreated')[:extract_event_number]
        for evt in evt_list:
            statement_json = json.loads(evt.statement)
            statement = {
                'actor': Agent.from_json(json.dumps(statement_json['actor'])),
                'verb': Verb.from_json(json.dumps(statement_json['verb'])),
                'object': Activity.from_json(json.dumps(statement_json['object'])),
                'timestamp': statement_json['timestamp'],
                'context': Context.from_json(json.dumps(statement_json['context'])),
            }
            evt.statement = json.dumps(statement)
            evt.tincan_error = "CONVERTED"
            evt.save()
Ejemplo n.º 2
0
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         Verb.from_json('{"test": "invalid property", "id": \
         "valid property"}')
Ejemplo n.º 3
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"bad JSON"}')
Ejemplo n.º 4
0
 def test_ToJSONFromJSON(self):
     json_str = '{"id": "test", "display": {"en-US": "test"}}'
     verb = Verb.from_json(json_str)
     self.assertEqual(verb.id, 'test')
     self.displayVerificationHelper(verb.display)
     self.assertEqual(json.loads(verb.to_json()), json.loads(json_str))
Ejemplo n.º 5
0
 def test_FromJSON(self):
     verb = Verb.from_json('{"id": "test", "display": {"en-US": "test"}}')
     self.assertEqual(verb.id, 'test')
     self.displayVerificationHelper(verb.display)
Ejemplo n.º 6
0
 def test_FromJSONExceptionFlatDisplay(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"id": "test", "display": "flatdisplay"}')
Ejemplo n.º 7
0
 def test_FromJSONId(self):
     verb = Verb.from_json('{"id": "test"}')
     self.assertEqual(verb.id, 'test')
Ejemplo n.º 8
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         Verb.from_json('')
Ejemplo n.º 9
0
 def test_FromJSONExceptionEmptyId(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"id":"''"}')
Ejemplo n.º 10
0
 def test_FromJSONEmptyObject(self):
     verb = Verb.from_json('{}')
     self.assertIsNone(verb.id)
Ejemplo n.º 11
0
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         Verb.from_json('{"test": "invalid property", "id": \
         "valid property"}')
Ejemplo n.º 12
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"bad JSON"}')
Ejemplo n.º 13
0
 def test_ToJSONFromJSON(self):
     json_str = '{"id": "test", "display": {"en-US": "test"}}'
     verb = Verb.from_json(json_str)
     self.assertEqual(verb.id, 'test')
     self.displayVerificationHelper(verb.display)
     self.assertEqual(verb.to_json(), json_str)
Ejemplo n.º 14
0
 def test_FromJSON(self):
     verb = Verb.from_json('{"id": "test", "display": {"en-US": "test"}}')
     self.assertEqual(verb.id, 'test')
     self.displayVerificationHelper(verb.display)
Ejemplo n.º 15
0
 def test_FromJSONExceptionFlatDisplay(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"id": "test", "display": "flatdisplay"}')
Ejemplo n.º 16
0
 def test_FromJSONEmptyObject(self):
     verb = Verb.from_json('{}')
     self.assertIsNone(verb.id)
Ejemplo n.º 17
0
 def test_FromJSONExceptionEmptyId(self):
     with self.assertRaises(ValueError):
         Verb.from_json('{"id":"''"}')
Ejemplo n.º 18
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         Verb.from_json('')
Ejemplo n.º 19
0
 def test_FromJSONId(self):
     verb = Verb.from_json('{"id": "test"}')
     self.assertEqual(verb.id, 'test')
Ejemplo n.º 20
0
 def test_FromJSONExceptionMalformedJSON(self):
     with self.assertRaises(AttributeError):
         verb = Verb.from_json('{"test": "invalid property"}')