Created
July 10, 2020 08:06
-
-
Save masouduut94/569b93db74160886ad0f8dae9bee16fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_add_bbox_to_frame(self): | |
# test if bbox is added to its own frame | |
frame_one_id = 0 | |
bbox_id = 1 | |
bbox_xywh = (10, 20, 30, 40) | |
top_k = 0 | |
self.json_parser.set_top_k(top_k) | |
self.json_parser.add_frame(frame_one_id) | |
self.json_parser.add_bbox_to_frame(frame_one_id, bbox_id, *bbox_xywh) | |
out = self.json_parser.output() | |
# retrieve the bbox in the frame | |
inserted_bbox = out['frames'][0]['bboxes'][0] | |
# check the values inserted in bbox | |
self.assertEqual((inserted_bbox['bbox_id']), bbox_id) | |
self.assertEqual(inserted_bbox['top'], bbox_xywh[0]) | |
self.assertEqual(inserted_bbox['left'], bbox_xywh[1]) | |
self.assertEqual(inserted_bbox['width'], bbox_xywh[2]) | |
self.assertEqual(inserted_bbox['height'], bbox_xywh[3]) | |
# check if error raises with repeated insertion | |
with self.assertRaisesRegex(ValueError, | |
'frame with frame_id: (.*?) already contains the bbox with id: (.*?) '): | |
self.json_parser.add_bbox_to_frame(frame_one_id, bbox_id, *bbox_xywh) | |
# check if error raises when frame_id is not recognized | |
with self.assertRaisesRegex(ValueError, | |
'frame with frame_id: (.*?) does not exist'): | |
self.json_parser.add_bbox_to_frame(2, bbox_id, *bbox_xywh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment