@@ -44,15 +44,29 @@ def build_url(self, *args, **kwargs):
44
44
return github3 .session .GitHubSession ().build_url (* args , ** kwargs )
45
45
46
46
47
- class UnitHelper (unittest .TestCase ):
47
+ def enterprise_build_url (self , * args , ** kwargs )
48
+ """A function to proxy to the actual GitHubSession#build_url method."""
49
+ # We want to assert what is happening with the actual calls to the
50
+ # Internet. We can proxy this.
51
+ return github3 .session .GitHubSession ().build_url (
52
+ * args ,
53
+ base_url = self .enterprise_url ,
54
+ ** kwargs
55
+ )
56
+
48
57
58
+ class UnitHelper (unittest .TestCase ):
49
59
"""Base class for unittests."""
50
60
51
61
# Sub-classes must assign the class to this during definition
52
62
described_class = None
53
63
# Sub-classes must also assign a dictionary to this during definition
54
64
example_data = {}
55
65
66
+ @staticmethod
67
+ def get_build_url_proxy ():
68
+ return build_url
69
+
56
70
def create_mocked_session (self ):
57
71
"""Use mock to auto-spec a GitHubSession and return an instance."""
58
72
MockedSession = mock .create_autospec (github3 .session .GitHubSession )
@@ -158,7 +172,7 @@ def setUp(self):
158
172
# we can assert things about the call that will be attempted to the
159
173
# internet
160
174
self .old_build_url = self .described_class ._build_url
161
- self .described_class ._build_url = build_url
175
+ self .described_class ._build_url = self . get_build_url_proxy ()
162
176
self .instance = self .create_instance_of_described_class ()
163
177
self .after_setup ()
164
178
@@ -239,42 +253,18 @@ def assert_requires_auth(self, func, *args, **kwargs):
239
253
240
254
241
255
class UnitGitHubObjectHelper (UnitHelper ):
242
-
243
256
"""Base class for GitHubObject unit tests."""
257
+ # TODO(sigmavirus24): delete me
244
258
245
- def setUp (self ):
246
- self .session = None
247
- self .instance = self .create_instance_of_described_class ()
248
- # Proxy the build_url method to the class so it can build the URL and
249
- # we can assert things about the call that will be attempted to the
250
- # internet
251
- self .described_class ._build_url = build_url
252
- self .after_setup ()
253
- pass
259
+ pass
254
260
255
261
256
262
@pytest .mark .usefixtures ('enterprise_url' )
257
263
class UnitGitHubEnterpriseHelper (UnitHelper ):
258
264
259
- def build_url (self , * args , ** kwargs ):
260
- """A function to proxy to the actual GitHubSession#build_url method."""
261
- # We want to assert what is happening with the actual calls to the
262
- # Internet. We can proxy this.
263
- return github3 .session .GitHubSession ().build_url (
264
- * args ,
265
- base_url = self .enterprise_url ,
266
- ** kwargs
267
- )
268
-
269
- def setUp (self ):
270
- self .session = self .create_session_mock ()
271
- self .instance = github3 .GitHubEnterprise (self .enterprise_url )
272
- self .instance .session = self .session
273
- # Proxy the build_url method to the class so it can build the URL and
274
- # we can assert things about the call that will be attempted to the
275
- # internet
276
- self .instance ._build_url = self .build_url
277
- self .after_setup ()
265
+ @staticmethod
266
+ def get_build_url_proxy ():
267
+ return enterprise_build_url
278
268
279
269
280
270
is_py3 = (3 , 0 ) <= sys .version_info < (4 , 0 )
0 commit comments