def test_collection_modified_when_annotation_updated(self): """Test Collection modified time updated when Annotation updated.""" collection = CollectionFactory() annotation = AnnotationFactory(collection=collection) data = annotation.dictize().copy() data['body'] = "My new body" endpoint = u'/annotations/{}/{}/'.format(collection.id, annotation.id) self.app_put_json_ld(endpoint, data=data) assert_not_equal(annotation.modified, None) assert_equal(collection.modified, annotation.modified)
def test_annotation_updated(self): """Test Annotation updated.""" collection = CollectionFactory() annotation = AnnotationFactory(collection=collection) data = annotation.dictize().copy() data['body'] = "My new body" assert_equal(annotation.modified, None) endpoint = u'/annotations/{}/{}/'.format(collection.id, annotation.id) res = self.app_put_json_ld(endpoint, data=data) # Test object updated assert_equal(annotation.modified, '1984-11-19T00:00:00Z') # Test data data = json.loads(res.data.decode('utf8')) assert_equal( data, { '@context': 'http://www.w3.org/ns/anno.jsonld', 'id': url_for('api.annotations', collection_id=collection.id, annotation_id=annotation.id), 'type': 'Annotation', 'body': data['body'], 'target': data['target'], 'created': '1984-11-19T00:00:00Z', 'generated': '1984-11-19T00:00:00Z', 'modified': '1984-11-19T00:00:00Z', 'generator': current_app.config.get('GENERATOR') }) # Test 200 assert_equal(res.status_code, 200, res.data) # Test Link header link = '<http://www.w3.org/ns/ldp#Resource>; rel="type"' assert_equal(res.headers.get('Link'), link)