@@ -14,24 +14,39 @@ class TestMagic:
14
14
15
15
api_secret_key = 'troll_goat'
16
16
17
+ @pytest .fixture (autouse = True )
18
+ def setup (self ):
19
+ self .mocked_resource_component = mock .Mock ()
20
+ self .mocked_request_client = mock .Mock (
21
+ request = mock .Mock (
22
+ return_value = mock .Mock (
23
+ data = {
24
+ 'client_id' : '1234' ,
25
+ },
26
+ ),
27
+ ),
28
+ )
29
+ with mock .patch (
30
+ 'magic_admin.magic.ResourceComponent' ,
31
+ return_value = self .mocked_resource_component ,
32
+ ), mock .patch (
33
+ 'magic_admin.magic.RequestsClient' ,
34
+ return_value = self .mocked_request_client ,
35
+ ):
36
+ yield
37
+
17
38
@pytest .fixture (autouse = True )
18
39
def teardown (self ):
19
40
yield
20
41
magic_admin .api_secret_key = None
21
42
22
43
def test_init (self ):
23
- mocked_rc = mock .Mock ()
24
-
25
44
with mock .patch (
26
- 'magic_admin.magic.ResourceComponent' ,
27
- return_value = mocked_rc ,
28
- ) as mock_resource_component , mock .patch (
29
45
'magic_admin.magic.Magic._set_api_secret_key' ,
30
46
) as mock_set_api_secret_key :
31
47
Magic (api_secret_key = self .api_secret_key )
32
48
33
- mock_resource_component .assert_called_once_with ()
34
- mocked_rc .setup_request_client .setup_request_client (
49
+ self .mocked_resource_component .setup_request_client .assert_called_once_with (
35
50
RETRIES ,
36
51
TIMEOUT ,
37
52
BACKOFF_FACTOR ,
0 commit comments