def test_screens_after_earliest_datetime(self): datetime = datetime_parse('2018-01-01T00:00:01+00:00') video = AnnotatedScreenVideo(INSTITUTION_ID, ROOM_ID, CAMERA_ID, datetime) frame = next(iter(video)) self.assertEqual( set([ ('aspect_ratio', datetime_parse('2018-01-01T00:00:00+00:00')), ('no_from_no_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('early_from_no_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('equal_from_no_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('late_from_no_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('no_from_early_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('no_from_equal_until', datetime_parse('2018-01-01T00:00:00+00:00')), ('no_from_late_until', datetime_parse('2018-01-01T00:00:00+00:00')), ]), set([(screen.screen_id, screen.datetime) for screen in self.screen_detector.detect(frame)]), )
def test_no_screens_before_earliest_datetime(self): datetime = datetime_parse('2017-12-31T23:59:59+00:00') video = AnnotatedScreenVideo(INSTITUTION_ID, ROOM_ID, CAMERA_ID, datetime) frame = next(iter(video)) screens = set(self.screen_detector.detect(frame)) self.assertEqual(screens, set())
def test_produces_single_frame(self): datetime = datetime_parse('2018-01-01T00:00:00+00:00') video = AnnotatedScreenVideo(INSTITUTION_ID, ROOM_ID, CAMERA_ID, datetime) frame_iterator = iter(video) next(frame_iterator) with self.assertRaises(StopIteration): next(frame_iterator)
def test_aspect_ratio(self): datetime = datetime_parse('2018-01-01T00:00:00+00:00') video = AnnotatedScreenVideo(INSTITUTION_ID, ROOM_ID, CAMERA_ID, datetime) frame = next(iter(video)) self.assertIn(('aspect_ratio', 133, 100), set([(screen.screen_id, screen.width, screen.height) for screen in self.screen_detector.detect(frame)]))
def test_video_dimensions(self): datetime = datetime_parse('2018-01-01T00:00:00+00:00') video = AnnotatedScreenVideo(INSTITUTION_ID, ROOM_ID, CAMERA_ID, datetime) self.assertEqual(VIDEO_WIDTH, video.width) self.assertEqual(VIDEO_HEIGHT, video.height)