Exemplo n.º 1
0
class EdgeTestCase(TestCase):
    def setUp(self):
        self.venue = Venue(name="MET Lab", lat=10.0, lng=20.0, website="http://projectjamjar.com", utc_offset=12)
        self.venue.save()

        self.concert = Concert(date="2016-01-01", venue=self.venue)
        self.concert.save()

        self.user = User(username='******', email='*****@*****.**', first_name='Test', last_name='Test', password='******')
        self.user.save()

        self.video1 = Video(concert_id=self.concert.id, length=10.0, user=self.user)
        self.video1.save()

        self.video2 = Video(concert_id=self.concert.id, length=10.0, user=self.user)
        self.video2.save()

        self.video3 = Video(concert_id=self.concert.id, length=10.0, user=self.user)
        self.video3.save()

        self.edge1 = Edge.new(video1_id=self.video1.id, video2_id=self.video2.id, confidence=10, offset=20.0)
        self.edge2 = Edge.new(video1_id=self.video2.id, video2_id=self.video3.id, confidence=11, offset=10.0)
        self.edge3 = Edge.new(video1_id=self.video1.id, video2_id=self.video3.id, confidence=12, offset=30.0)

    def test_edge(self):
        edge = Edge.new(self.video1.id, self.video2.id, 0, 1)
        self.assertTrue(edge.id is not None)
Exemplo n.º 2
0
    def test_transcode(self):
        success = self.video_transcoder.transcode_to_hls(TEST_VIDEO_PATH_1, TEST_HLS_PATH)
        self.assertTrue(success, 'Error transcoding video')

        out_dir = os.path.join(os.path.dirname(__file__), 'out')

        uploaded = []
        deleted  = []

        def mocked_upload(s3_path, file_path):
            uploaded.append((s3_path, file_path))

        def mocked_delete(src_dir):
            deleted.append(src_dir)

        self.video_transcoder.do_upload_to_s3 = mocked_upload
        self.video_transcoder.delete_source   = mocked_delete
        self.video_transcoder.upload_to_s3(out_dir)

        self.assertTrue(('test/out/part1.hls', TEST_HLS_PATH) in uploaded)
        self.assertTrue(('test/out/part10.ts', TEST_TS_PATH) in uploaded)
        self.assertTrue(len(uploaded) == 2)

        venue = Venue(name="MET Lab")
        venue.save()

        concert = Concert(date="2016-01-01", venue=venue)
        concert.save()


        v1 = Video(concert_id=concert.id, length=2)
        v1.save()

        v2 = Video(concert_id=concert.id, length=2)
        v2.save()

        length_1 = self.video_transcoder.fingerprint(TEST_VIDEO_PATH_1, v1.id)
        length_2 = self.video_transcoder.fingerprint(TEST_VIDEO_PATH_2, v2.id)

        self.assertTrue(abs(5 - length_1) < .1)
        self.assertTrue(abs(5 - length_2) < .1)
Exemplo n.º 3
0
class ConcertTestCase(TestCase):
    def setUp(self):
        self.venue = Venue(name="MET Lab", lat=10.0, lng=20.0, website="http://projectjamjar.com", utc_offset=12)
        self.venue.save()

        self.concert = Concert(date="2016-01-01", venue=self.venue)
        self.concert.save()

        self.user = User(username='******', email='*****@*****.**', first_name='Test', last_name='Test', password='******')
        self.user.save()

        self.video1 = Video(name="video1", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video1.save()

        self.video2 = Video(name="video2", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video2.save()

        self.video3 = Video(name="video3", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video3.save()

        self.edge1 = Edge.new(video1_id=self.video1.id, video2_id=self.video2.id, confidence=30, offset=20.0)
        self.edge2 = Edge.new(video1_id=self.video2.id, video2_id=self.video3.id, confidence=40, offset=10.0)
        self.edge3 = Edge.new(video1_id=self.video1.id, video2_id=self.video3.id, confidence=50, offset=30.0)

    @skip('skipping graph tests')
    def test_graph_generation(self):
        graph = self.concert.make_graph()


        # TODO: Improve test cases so they map back to requirements
        self.assertEqual(len(graph), 3)
        self.assertEqual(sorted([i['video']['name'] for i in graph]), ['video1', 'video2', 'video3'])

        for item in graph:
            self.assertEqual(len(item['connects_to']), 2)
            self.assertTrue(item['video']['id'] not in [j['video']['id'] for j in item['connects_to']])

            for connection in item['connects_to']:
                self.assertTrue('confidence' in connection['edge'])
                self.assertTrue('offset' in connection['edge'])
Exemplo n.º 4
0
    def setUp(self):
        self.venue = Venue(name="MET Lab", lat=10.0, lng=20.0, website="http://projectjamjar.com", utc_offset=12)
        self.venue.save()

        self.concert = Concert(date="2016-01-01", venue=self.venue)
        self.concert.save()

        self.user = User(username='******', email='*****@*****.**', first_name='Test', last_name='Test', password='******')
        self.user.save()

        self.video1 = Video(name="video1", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video1.save()
        
        self.video_transcoder = VideoTranscoder()
        self.truncateTestDb()
Exemplo n.º 5
0
    def setUp(self):
        self.venue = Venue(name="MET Lab", lat=10.0, lng=20.0, website="http://projectjamjar.com", utc_offset=12)
        self.venue.save()

        self.concert = Concert(date="2016-01-01", venue=self.venue)
        self.concert.save()

        self.user = User(username='******', email='*****@*****.**', first_name='Test', last_name='Test', password='******')
        self.user.save()

        self.video1 = Video(name="video1", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video1.save()

        self.video2 = Video(name="video2", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video2.save()

        self.video3 = Video(name="video3", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video3.save()

        self.edge1 = Edge.new(video1_id=self.video1.id, video2_id=self.video2.id, confidence=30, offset=20.0)
        self.edge2 = Edge.new(video1_id=self.video2.id, video2_id=self.video3.id, confidence=40, offset=10.0)
        self.edge3 = Edge.new(video1_id=self.video1.id, video2_id=self.video3.id, confidence=50, offset=30.0)
Exemplo n.º 6
0
class LiloTestCase(TestCase):
    def truncateTestDb(self):
        if 'test' in settings.LILO_CONFIG['database']['db']:
            lilo = Lilo(settings.LILO_CONFIG, None, None)
            lilo.djv.db.empty()
        else:
            raise RuntimeError("trying to truncate a non-test table!")

    def tearDown(self):
        os.remove(TEST_HLS_PATH)
        os.remove(TEST_TS_PATH)
        self.truncateTestDb()

    def setUp(self):
        self.venue = Venue(name="MET Lab", lat=10.0, lng=20.0, website="http://projectjamjar.com", utc_offset=12)
        self.venue.save()

        self.concert = Concert(date="2016-01-01", venue=self.venue)
        self.concert.save()

        self.user = User(username='******', email='*****@*****.**', first_name='Test', last_name='Test', password='******')
        self.user.save()

        self.video1 = Video(name="video1", concert_id=self.concert.id, length=10.0, user=self.user)
        self.video1.save()
        
        self.video_transcoder = VideoTranscoder()
        self.truncateTestDb()

    @skip('need to redo this test')
    def test_transcode(self):
        success = self.video_transcoder.transcode_to_hls(TEST_VIDEO_PATH_1, TEST_HLS_PATH)
        self.assertTrue(success, 'Error transcoding video')

        out_dir = os.path.join(os.path.dirname(__file__), 'out')

        uploaded = []
        deleted  = []

        def mocked_upload(s3_path, file_path):
            uploaded.append((s3_path, file_path))

        def mocked_delete(src_dir):
            deleted.append(src_dir)

        self.video_transcoder.do_upload_to_s3 = mocked_upload
        self.video_transcoder.delete_source   = mocked_delete
        self.video_transcoder.upload_to_s3(out_dir)

        self.assertTrue(('test/out/part1.hls', TEST_HLS_PATH) in uploaded)
        self.assertTrue(('test/out/part10.ts', TEST_TS_PATH) in uploaded)
        self.assertTrue(len(uploaded) == 2)

        venue = Venue(name="MET Lab")
        venue.save()

        concert = Concert(date="2016-01-01", venue=venue)
        concert.save()


        v1 = Video(concert_id=concert.id, length=2)
        v1.save()

        v2 = Video(concert_id=concert.id, length=2)
        v2.save()

        length_1 = self.video_transcoder.fingerprint(TEST_VIDEO_PATH_1, v1.id)
        length_2 = self.video_transcoder.fingerprint(TEST_VIDEO_PATH_2, v2.id)

        self.assertTrue(abs(5 - length_1) < .1)
        self.assertTrue(abs(5 - length_2) < .1)