1
1
import datetime
2
+ from unittest .mock import patch
2
3
3
4
import pytest
4
5
import responses
5
- from unittest .mock import patch
6
6
7
7
from sentry .codecov .client import CodecovApiClient , ConfigurationError , GitProvider
8
8
from sentry .testutils .cases import TestCase
@@ -20,25 +20,31 @@ def setUp(self):
20
20
self .test_timestamp = datetime .datetime .now (datetime .UTC )
21
21
self ._mock_now = patch ("datetime.datetime.now" , return_value = self .test_timestamp )
22
22
23
- with self .options ({
24
- "codecov.base-url" : self .test_base_url ,
25
- "codecov.api-bridge-signing-secret" : self .test_secret ,
26
- }):
23
+ with self .options (
24
+ {
25
+ "codecov.base-url" : self .test_base_url ,
26
+ "codecov.api-bridge-signing-secret" : self .test_secret ,
27
+ }
28
+ ):
27
29
self .codecov_client = CodecovApiClient (self .test_git_provider_user )
28
30
29
31
def test_raises_configuration_error_without_base_url (self ):
30
- with self .options ({
31
- "codecov.base-url" : None ,
32
- "codecov.api-bridge-signing-secret" : self .test_secret ,
33
- }):
32
+ with self .options (
33
+ {
34
+ "codecov.base-url" : None ,
35
+ "codecov.api-bridge-signing-secret" : self .test_secret ,
36
+ }
37
+ ):
34
38
with pytest .raises (ConfigurationError ):
35
39
CodecovApiClient (self .test_git_provider_user )
36
40
37
41
def test_raises_configuration_error_without_signing_secret (self ):
38
- with self .options ({
39
- "codecov.base-url" : self .test_base_url ,
40
- "codecov.api-bridge-signing-secret" : None ,
41
- }):
42
+ with self .options (
43
+ {
44
+ "codecov.base-url" : self .test_base_url ,
45
+ "codecov.api-bridge-signing-secret" : None ,
46
+ }
47
+ ):
42
48
with pytest .raises (ConfigurationError ):
43
49
CodecovApiClient (self .test_git_provider_user )
44
50
@@ -70,7 +76,9 @@ def test_creates_valid_jwt(self):
70
76
@patch ("requests.get" )
71
77
def test_sends_get_request_with_jwt_auth_header (self , mock_get ):
72
78
with patch .object (self .codecov_client , "_create_jwt" , return_value = "test" ):
73
- self .codecov_client .get ("/example/endpoint" , {"example-param" : "foo" }, {"X_TEST_HEADER" : "bar" })
79
+ self .codecov_client .get (
80
+ "/example/endpoint" , {"example-param" : "foo" }, {"X_TEST_HEADER" : "bar" }
81
+ )
74
82
mock_get .assert_called_once_with (
75
83
"http://example.com/example/endpoint" ,
76
84
params = {"example-param" : "foo" },
@@ -84,7 +92,9 @@ def test_sends_get_request_with_jwt_auth_header(self, mock_get):
84
92
@patch ("requests.post" )
85
93
def test_sends_post_request_with_jwt_auth_header (self , mock_post ):
86
94
with patch .object (self .codecov_client , "_create_jwt" , return_value = "test" ):
87
- self .codecov_client .post ("/example/endpoint" , {"example-param" : "foo" }, {"X_TEST_HEADER" : "bar" })
95
+ self .codecov_client .post (
96
+ "/example/endpoint" , {"example-param" : "foo" }, {"X_TEST_HEADER" : "bar" }
97
+ )
88
98
mock_post .assert_called_once_with (
89
99
"http://example.com/example/endpoint" ,
90
100
data = {"example-param" : "foo" },
0 commit comments