def test_annotation_action_get_empty(self):
response = self.test_client.get(reverse('annotation-action', kwargs={'sound_id': self.sound.id,
'tier_id': self.tier.id}))
self.assertEqual(response.status_code, 200)
response_data = response.json()
# no segments are created
self.assertEqual(response_data['task']['segments'], [])
# create annotation in reference sound that should be in the response
reference_annotation = Annotation.objects.create(name='reference_annotation', start_time=1.000, end_time=2.000,
sound=self.reference_sound, tier=self.tier, user=self.user)
response = self.test_client.get(reverse('annotation-action', kwargs={'sound_id': self.sound.id,
'tier_id': self.tier.id}))
self.assertEqual(response.json()['task']['segments_ref'][0]['annotation'], reference_annotation.name)
self.assertEqual(float(response.json()['task']['segments_ref'][0]['start']), reference_annotation.start_time)
self.assertEqual(float(response.json()['task']['segments_ref'][0]['end']), reference_annotation.end_time)
self.assertEqual(response.json()['task']['url'], os.path.join(settings.MEDIA_URL, self.data_set.name,
self.exercise.name, self.sound.filename))
评论列表
文章目录