-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize_image_tests.py
More file actions
26 lines (20 loc) · 892 Bytes
/
Copy pathvisualize_image_tests.py
File metadata and controls
26 lines (20 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest.mock as mock
import pytest
from visualize_image import VideoDetectionHandler
def test_create_handle_detection_request(create_handle_detection_request):
"""
Tests that the input data is serialized okay into the protobuf types without errors
Receives a fixture function defined in proto.conftest.py which is loaded by pytest
"""
msg, string_map, float_map, category_index = create_handle_detection_request
handler = VideoDetectionHandler("/test/path/to/labels")
# mocks
handler.video_writer = mock.Mock()
handler.category_index = category_index
handler.output_video_file_path = mock.Mock()
handler.handle_detection(msg, mock.Mock())
# assertions
handler.video_writer.write.assert_called_once()
# https://www.avivroth.com/2018/03/06/python-embedding-pytest-in-code/
if __name__ == "__main__":
pytest.main([__file__])