File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed
Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ def add_target(
100100 name : str ,
101101 width : Union [int , float ],
102102 image : io .BytesIO ,
103+ active_flag : bool = True ,
103104 ) -> str :
104105 """
105106 Add a target to a Vuforia Web Services database.
@@ -108,19 +109,19 @@ def add_target(
108109 name: The name of the target.
109110 width: The width of the target.
110111 image: The image of the target.
112+ active_flag: Whether or not the target is active for query.
111113
112114 Returns:
113115 The target ID of the new target.
114116 """
115117 image_data = image .getvalue ()
116118 image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
117- metadata_encoded = None
118119
119120 data = {
120121 'name' : name ,
121122 'width' : width ,
122123 'image' : image_data_encoded ,
123- 'application_metadata ' : metadata_encoded ,
124+ 'active_flag ' : active_flag ,
124125 }
125126
126127 content = bytes (json .dumps (data ), encoding = 'utf-8' )
Original file line number Diff line number Diff line change 44
55import io
66
7+ import pytest
78from mock_vws import MockVWS
89
910from vws import VWS
@@ -70,3 +71,47 @@ def test_custom_base_url(self, high_quality_image: io.BytesIO) -> None:
7071 width = 1 ,
7172 image = high_quality_image ,
7273 )
74+
75+
76+ class TestActiveFlag :
77+ """
78+ Tests for the ``active_flag`` parameter to ``add_target``.
79+ """
80+
81+ def test_default (
82+ self ,
83+ client : VWS ,
84+ high_quality_image : io .BytesIO ,
85+ ) -> None :
86+ """
87+ By default, the active flag is set to ``True``.
88+ """
89+ target_id = client .add_target (
90+ name = 'x' ,
91+ width = 1 ,
92+ image = high_quality_image ,
93+ )
94+ get_result = client .get_target (target_id = target_id )
95+ target_record = get_result ['target_record' ]
96+ assert target_record ['active_flag' ] is True
97+
98+ @pytest .mark .parametrize ('active_flag' , [True , False ])
99+ def test_given (
100+ self ,
101+ client : VWS ,
102+ high_quality_image : io .BytesIO ,
103+ active_flag : bool ,
104+ ) -> None :
105+ """
106+ It is possible to set the active flag to a boolean value.
107+ """
108+ target_id = client .add_target (
109+ name = 'x' ,
110+ width = 1 ,
111+ image = high_quality_image ,
112+ active_flag = active_flag ,
113+ )
114+
115+ get_result = client .get_target (target_id = target_id )
116+ target_record = get_result ['target_record' ]
117+ assert target_record ['active_flag' ] is active_flag
You can’t perform that action at this time.
0 commit comments