コード例 #1
0
    def test_delete(self):
        id_ = str(uuid.uuid4())
        ann = Annotation(id=id_)
        ann.save()

        newann = Annotation.get(id_)
        newann.delete()

        noann = Annotation.get(id_)
        assert noann == None
コード例 #2
0
 def test_extras_in(self):
     ann = Annotation.from_dict({'foo':1, 'bar':2})
     ann.save()
     ann = Annotation.get(ann.id)
     extras = dict(ann.items())
     print extras
     assert 'foo' in extras.keys(), "extras weren't serialized properly"
     assert 'bar' in extras.keys(), "extras weren't serialized properly"
     assert ann['foo'] == 1, "extras weren't serialized properly"
     assert ann['bar'] == 2, "extras weren't serialized properly"
コード例 #3
0
 def test_01_text(self):
     user = {"id": "Alice", "name": "Alice Wonderland"}
     ann = Annotation(text="Hello there", user=user)
     ann.ranges.append({})
     ann.ranges.append({})
     ann.save()
     ann = Annotation.get(ann.id)
     assert ann.text == "Hello there", "annotation text wasn't set"
     assert ann.user['id'] == "Alice", "annotation user wasn't set"
     assert ann.user['name'] == "Alice Wonderland", "annotation user wasn't set"
     assert len(ann.ranges) == 2, "ranges weren't added to annotation"