33"""
44
55import io
6+ from typing import Optional
67
78import pytest
89from mock_vws import MockVWS
910
1011from vws import VWS
1112
1213
13- class TestSuccess :
14+ class TestAddTarget :
1415 """
15- Tests for successfully adding a target.
16+ Tests for adding a target.
1617 """
1718
1819 def test_add_target (
@@ -48,39 +49,8 @@ def test_add_two_targets(
4849 client .add_target (name = 'x' , width = 1 , image = high_quality_image )
4950 client .add_target (name = 'a' , width = 1 , image = high_quality_image )
5051
51-
52- class TestCustomBaseURL :
53- """
54- Tests for adding images to databases under custom VWS URLs.
55- """
56-
57- def test_custom_base_url (self , high_quality_image : io .BytesIO ) -> None :
58- """
59- It is possible to use add a target to a database under a custom VWS
60- URL.
61- """
62- base_vws_url = 'http://example.com'
63- with MockVWS (base_vws_url = base_vws_url ) as mock :
64- client = VWS (
65- server_access_key = mock .server_access_key ,
66- server_secret_key = mock .server_secret_key ,
67- base_vws_url = base_vws_url ,
68- )
69-
70- client .add_target (
71- name = 'x' ,
72- width = 1 ,
73- image = high_quality_image ,
74- )
75-
76-
77- class TestApplicationMetadata :
78- """
79- Tests for the ``application_metadata`` parameter to ``add_target``.
80- """
81-
8252 @pytest .mark .parametrize ('application_metadata' , [None , b'a' ])
83- def test_valid (
53+ def test_valid_metadata (
8454 self ,
8555 client : VWS ,
8656 high_quality_image : io .BytesIO ,
@@ -96,30 +66,8 @@ def test_valid(
9666 application_metadata = None ,
9767 )
9868
99-
100- class TestActiveFlag :
101- """
102- Tests for the ``active_flag`` parameter to ``add_target``.
103- """
104-
105- def test_default (
106- self ,
107- client : VWS ,
108- high_quality_image : io .BytesIO ,
109- ) -> None :
110- """
111- By default, the active flag is set to ``True``.
112- """
113- target_id = client .add_target (
114- name = 'x' ,
115- width = 1 ,
116- image = high_quality_image ,
117- )
118- target_record = client .get_target_record (target_id = target_id )
119- assert target_record ['active_flag' ] is True
120-
12169 @pytest .mark .parametrize ('active_flag' , [True , False ])
122- def test_given (
70+ def test_active_flag_given (
12371 self ,
12472 client : VWS ,
12573 high_quality_image : io .BytesIO ,
@@ -136,3 +84,28 @@ def test_given(
13684 )
13785 target_record = client .get_target_record (target_id = target_id )
13886 assert target_record ['active_flag' ] is active_flag
87+
88+
89+ class TestCustomBaseVWSURL :
90+ """
91+ Tests for using a custom base VWS URL.
92+ """
93+
94+ def test_custom_base_url (self , high_quality_image : io .BytesIO ) -> None :
95+ """
96+ It is possible to use add a target to a database under a custom VWS
97+ URL.
98+ """
99+ base_vws_url = 'http://example.com'
100+ with MockVWS (base_vws_url = base_vws_url ) as mock :
101+ client = VWS (
102+ server_access_key = mock .server_access_key ,
103+ server_secret_key = mock .server_secret_key ,
104+ base_vws_url = base_vws_url ,
105+ )
106+
107+ client .add_target (
108+ name = 'x' ,
109+ width = 1 ,
110+ image = high_quality_image ,
111+ )
0 commit comments