Beispiel #1
0
    def test_update_track_elements(self):
        self.asset.update_track_elements([], [])
        self.assertEqual(SequenceMediaElement.objects.count(), 0)
        self.assertEqual(SequenceTextElement.objects.count(), 0)

        media_track = []
        for i in range(3):
            e = SequenceMediaElementFactory(sequence_asset=self.asset)
            media_track.append({
                'start_time': i,
                'end_time': i + 0.5,
                'media': e.media,
            })

        text_track = []
        for i in range(4):
            e = SequenceTextElementFactory(sequence_asset=self.asset)
            text_track.append({
                'start_time': i,
                'end_time': i + 0.5,
                'text': 'text {}'.format(i),
            })

        self.asset.update_track_elements(media_track, text_track)
        self.assertEqual(SequenceMediaElement.objects.count(), 3)
        self.assertEqual(SequenceTextElement.objects.count(), 4)

        el0 = SequenceTextElement.objects.filter(text='text 0').first()
        self.assertEqual(el0.start_time, 0)
        self.assertEqual(el0.end_time, 0.5)
        self.assertEqual(el0.sequence_asset, self.asset)
 def test_retrieve_with_text_elements(self):
     note = SherdNoteFactory()
     asset = SequenceAssetFactory(author=self.u, spine=note)
     e1 = SequenceTextElementFactory(sequence_asset=asset)
     e2 = SequenceTextElementFactory(sequence_asset=asset)
     e3 = SequenceTextElementFactory(sequence_asset=asset)
     r = self.client.get(
         reverse('sequenceasset-detail', args=(asset.pk,)), format='json'
     )
     self.assertEqual(r.status_code, 200)
     the_json = loads(r.content)
     self.assertEqual(the_json['spine']['id'], note.pk)
     textelements = the_json['text_elements']
     self.assertEqual(textelements[0]['text'], e1.text)
     self.assertEqual(textelements[1]['text'], e2.text)
     self.assertEqual(textelements[2]['text'], e3.text)
Beispiel #3
0
 def setUp(self):
     self.item = SequenceTextElementFactory()
Beispiel #4
0
class SequenceTextElementTest(TestCase):
    def setUp(self):
        self.item = SequenceTextElementFactory()

    def test_is_valid_from_factory(self):
        self.item.full_clean()
Beispiel #5
0
 def setUp(self):
     self.item = SequenceTextElementFactory()
Beispiel #6
0
class SequenceTextElementTest(TestCase):
    def setUp(self):
        self.item = SequenceTextElementFactory()

    def test_is_valid_from_factory(self):
        self.item.full_clean()