

def testPartAnnotation(self):
    'this is more about testing the annotatext app '
    self.assertTrue(self.client.login(username='jacob', password='JKM'))
    part = self.meeting_1.parts.list()[0]
    res = self.client.post(reverse('annotatetext-post_annotation'), {
        'selection_start': 7,
        'selection_end': 14,
        'flags': 0,
        'color': '#000',
        'lengthcheck': len(part.body),
        'comment': 'just perfect',
        'object_id': part.id,
        'content_type': ContentType.objects.get_for_model(part).id,
    })
    self.assertEqual(res.status_code, 302)
    annotation = Annotation.objects.get(object_id=part.id, content_type=ContentType.objects.get_for_model(part).id)
    self.assertEqual(annotation.selection, 'perfect')
    stream = Action.objects.stream_for_actor(self.jacob)
    self.assertEqual(stream.count(), 2)
    self.assertEqual(stream[0].verb, 'started following')
    self.assertEqual(stream[0].target.id, self.meeting_1.id)
    self.assertEqual(stream[1].verb, 'annotated')
    self.assertEqual(stream[1].target.id, annotation.id)
    annotations = self.committee_1.annotations
    self.assertEqual(annotations.count(), 1)
    self.assertEqual(annotations[0].comment, 'just perfect')
    annotation.delete()
    stream = Action.objects.stream_for_actor(self.jacob)
    self.assertEqual(stream.count(), 1)

dataset/ETHPy150Open ofri/Open-Knesset/committees/tests.py CommitteeMeetingDetailViewTest.testPartAnnotation/original