@@ -61,33 +61,58 @@ To write unit tests for code which uses this library, without using your Vuforia
6161
6262 pip3 install vws-python-mock
6363
64- .. code :: python
64+ .. testsetup ::
65+
66+ import pathlib
67+ import shutil
68+
69+ import vws_test_fixtures
6570
66- from mock_vws import MockVWS, VuforiaDatabase
71+ # We rely on implementation details of the fixtures package.
72+ image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg'
73+ assert image.exists(), image.resolve()
74+ new_image = pathlib.Path('high_quality_image.jpg')
75+ shutil.copy(image, new_image)
76+
77+ .. testcode ::
78+
79+ import io
80+ import pathlib
81+
82+ from mock_vws.database import VuforiaDatabase
83+ from mock_vws import MockVWS
84+ from vws import CloudRecoService, VWS
6785
6886 with MockVWS() as mock:
6987 database = VuforiaDatabase()
7088 mock.add_database(database=database)
7189 vws_client = VWS(
72- server_access_key = server_access_key,
73- server_secret_key = server_secret_key,
90+ server_access_key=database. server_access_key,
91+ server_secret_key=database. server_secret_key,
7492 )
7593 cloud_reco_client = CloudRecoService(
76- client_access_key = client_access_key,
77- client_secret_key = client_secret_key,
94+ client_access_key=database. client_access_key,
95+ client_secret_key=database. client_secret_key,
7896 )
7997
80- name = ' my_image_name'
8198
82- with open (' /path/to/image.png' , ' rb' ) as my_image_file:
99+ image = pathlib.Path('high_quality_image.jpg')
100+ with image.open(mode='rb') as my_image_file:
83101 my_image = io.BytesIO(my_image_file.read())
84102
85103 target_id = vws_client.add_target(
86- name = name ,
104+ name="example_image_name" ,
87105 width=1,
88106 image=my_image,
107+ application_metadata=None,
108+ active_flag=True,
89109 )
90110
111+ .. testcleanup ::
112+
113+ new_image = pathlib.Path('high_quality_image.jpg')
114+ new_image.unlink()
115+
91116There are some differences between the mock and the real Vuforia.
92117See https://vws-python-mock.readthedocs.io/en/latest/differences-to-vws.html for details.
93118
0 commit comments