@@ -74,34 +74,34 @@ def __init__(self, *args, **kwarg):
74
74
self ._did_request_fetch = None
75
75
76
76
def pull (self , * args , ** kwarg ):
77
- self ._did_pull = (args , kwarg )
77
+ self .__class__ . _current . _did_pull = (args , kwarg )
78
78
79
79
def clone (self , * args , ** kwarg ):
80
- self ._did_clone = (args , kwarg )
80
+ self .__class__ . _current . _did_clone = (args , kwarg )
81
81
82
82
def add (self , repo , user = None , * args , ** kwarg ):
83
- self ._did_add = ((user , repo )+ args , kwarg )
83
+ self .__class__ . _current . _did_add = ((user , repo )+ args , kwarg )
84
84
class FakeRemote :
85
85
name = 'foobar'
86
86
return FakeRemote , user , repo
87
87
88
88
def open (self , * args , ** kwarg ):
89
- self ._did_open = (args , kwarg )
89
+ self .__class__ . _current . _did_open = (args , kwarg )
90
90
91
91
def connect (self ):
92
- self ._did_connect = True
92
+ self .__class__ . _current . _did_connect = True
93
93
94
94
def delete (self , * args , ** kwarg ):
95
- self ._did_delete = (tuple (reversed (args )), kwarg )
95
+ self .__class__ . _current . _did_delete = (tuple (reversed (args )), kwarg )
96
96
97
97
def create (self , * args , ** kwarg ):
98
- self ._did_create = (args , kwarg )
98
+ self .__class__ . _current . _did_create = (args , kwarg )
99
99
100
100
def fork (self , * args , ** kwarg ):
101
- self ._did_fork = (args , kwarg )
101
+ self .__class__ . _current . _did_fork = (args , kwarg )
102
102
103
103
def gist_list (self , * args , ** kwarg ):
104
- self ._did_gist_list = (args , kwarg )
104
+ self .__class__ . _current . _did_gist_list = (args , kwarg )
105
105
if len (args ) == 0 or not args [0 ]:
106
106
yield '{} {}'
107
107
yield 'title' , 'url'
@@ -119,7 +119,7 @@ def gist_list(self, *args, **kwarg):
119
119
yield 'lang3' , 'size3' , 'name3'
120
120
121
121
def gist_fetch (self , * args , ** kwarg ):
122
- self ._did_gist_fetch = (args , kwarg )
122
+ self .__class__ . _current . _did_gist_fetch = (args , kwarg )
123
123
if args [0 ] == 'bad' :
124
124
raise Exception ('bad gist!' )
125
125
elif args [1 ] == 'bad' :
@@ -128,50 +128,56 @@ def gist_fetch(self, *args, **kwarg):
128
128
return "content of a gist"
129
129
130
130
def gist_clone (self , * args , ** kwarg ):
131
- self ._did_gist_clone = (args , kwarg )
131
+ self .__class__ . _current . _did_gist_clone = (args , kwarg )
132
132
if args [0 ] == 'bad' :
133
133
raise Exception ('bad gist!' )
134
134
135
135
def gist_create (self , * args , ** kwarg ):
136
- self ._did_gist_create = (args , kwarg )
136
+ self .__class__ . _current . _did_gist_create = (args , kwarg )
137
137
if 'exists' in args [0 ]:
138
138
raise Exception ('gist exists!' )
139
139
return 'https://gists/42'
140
140
141
141
def gist_delete (self , * args , ** kwarg ):
142
- self ._did_gist_delete = (args , kwarg )
142
+ self .__class__ . _current . _did_gist_delete = (args , kwarg )
143
143
if args [0 ] == 'bad' :
144
144
raise Exception ('bad gist!' )
145
145
146
146
def request_list (self , * args , ** kwarg ):
147
- self ._did_request_list = (args , kwarg )
147
+ self .__class__ . _current . _did_request_list = (args , kwarg )
148
148
yield '{} {} {}'
149
149
yield ('id' , 'description' , 'URL' )
150
150
yield ('1' , 'desc1' , 'http://request/1' )
151
151
yield ('2' , 'desc2' , 'http://request/2' )
152
152
yield ('3' , 'desc3' , 'http://request/3' )
153
153
154
154
def request_fetch (self , * args , ** kwarg ):
155
- self ._did_request_fetch = (args , kwarg )
155
+ self .__class__ . _current . _did_request_fetch = (args , kwarg )
156
156
if args [- 1 ] == 'bad' :
157
157
raise Exception ('bad request for merge!' )
158
158
return "pr/42"
159
159
160
160
def request_create (self , * args , ** kwarg ):
161
- self ._did_request_create = (args , kwarg )
161
+ self .__class__ . _current . _did_request_create = (args , kwarg )
162
162
if args [2 ] == 'bad' or args [3 ] == 'bad' :
163
163
raise Exception ('bad branch to request!' )
164
164
local = args [2 ] or 'pr-test'
165
165
remote = args [3 ] or 'base-test'
166
- return {'local' : local , 'remote' : remote , 'project' : '/' .join (args [:2 ]), 'ref' : 42 }
166
+ # return
167
+ yield '{}'
168
+ yield ['Successfully created request of `{local}` onto `{project}:{remote}, with id `{ref}' .format (
169
+ ** {'local' : local , 'remote' : remote , 'project' : '/' .join (args [:2 ]), 'ref' : 42 }
170
+ )]
171
+ yield ['available at {}' .format ('https://...' )]
172
+
167
173
168
174
@classmethod
169
175
def get_auth_token (cls , login , password , prompt = None ):
170
176
return '{}:{}' .format (login , password )
171
177
172
178
@property
173
179
def user (self ):
174
- self ._did_user = True
180
+ self .__class__ . _current . _did_user = True
175
181
return 'foobar'
176
182
177
183
def get_repository (self , * args , ** kwarg ):
@@ -181,6 +187,7 @@ def get_repository(self, *args, **kwarg):
181
187
class GitRepoMainTestCase (TestGitPopenMockupMixin ):
182
188
def setup_method (self , method ):
183
189
self .log .info ('GitRepoMainTestCase.setup_method({})' .format (method ))
190
+ RepositoryService ._current = RepositoryMockup (c = {})
184
191
self .tempdir = TemporaryDirectory ()
185
192
RepositoryService .service_map = {
186
193
'github' : RepositoryMockup ,
@@ -197,7 +204,6 @@ def setup_method(self, method):
197
204
198
205
def teardown_method (self , method ):
199
206
self .log .info ('GitRepoMainTestCase.teardown_method({})' .format (method ))
200
- RepositoryService ._current = RepositoryMockup (c = {})
201
207
self .tempdir .cleanup ()
202
208
203
209
def setup_args (self , d , args = {}):
@@ -215,7 +221,6 @@ def setup_args(self, d, args={}):
215
221
'<branch>' : None ,
216
222
'<target>' : self .target ,
217
223
'<target_repo>' : None ,
218
- '<user>/<repo>' : '' ,
219
224
'add' : False ,
220
225
'clone' : False ,
221
226
'create' : False ,
@@ -237,7 +242,7 @@ def setup_args(self, d, args={}):
237
242
'<request>' : None ,
238
243
'<local_branch>' : None ,
239
244
'<remote_branch>' : None ,
240
- '<user >/<repo>' : None ,
245
+ '<namespace >/<repo>' : None ,
241
246
}
242
247
cli_args .update (d )
243
248
cli_args .update (args )
@@ -252,15 +257,15 @@ def main_add(self, repo, rc=0, args={}):
252
257
Repo .init (os .path .join (self .tempdir .name , create_repo ))
253
258
assert rc == main (self .setup_args ({
254
259
'add' : True ,
255
- '<user >/<repo>' : repo ,
260
+ '<namespace >/<repo>' : repo ,
256
261
'--path' : self .tempdir .name
257
262
}, args )), "Non {} result for add" .format (rc )
258
263
return RepositoryService ._current ._did_add
259
264
260
265
def main_clone (self , repo , rc = 0 , args = {}):
261
266
assert rc == main (self .setup_args ({
262
267
'clone' : True ,
263
- '<user >/<repo>' : repo ,
268
+ '<namespace >/<repo>' : repo ,
264
269
'--path' : self .tempdir .name
265
270
}, args )), "Non {} result for clone" .format (rc )
266
271
return RepositoryService ._current ._did_clone
@@ -272,7 +277,7 @@ def main_create(self, repo=None, rc=0, args={}):
272
277
Repo .init (repo_path )
273
278
assert rc == main (self .setup_args ({
274
279
'create' : True ,
275
- '<user >/<repo>' : repo ,
280
+ '<namespace >/<repo>' : repo ,
276
281
'--path' : self .tempdir .name
277
282
}, args )), "Non {} result for create" .format (rc )
278
283
return RepositoryService ._current ._did_create
@@ -284,15 +289,15 @@ def main_delete(self, repo=None, rc=0, args={}):
284
289
Repo .init (repo_path )
285
290
assert rc == main (self .setup_args ({
286
291
'delete' : True ,
287
- '<user >/<repo>' : repo ,
292
+ '<namespace >/<repo>' : repo ,
288
293
'--path' : self .tempdir .name ,
289
294
}, args )), "Non {} result for delete" .format (rc )
290
295
return RepositoryService ._current ._did_delete
291
296
292
297
def main_fork (self , repo = None , rc = 0 , args = {}):
293
298
assert rc == main (self .setup_args ({
294
299
'fork' : True ,
295
- '<user >/<repo>' : repo ,
300
+ '<namespace >/<repo>' : repo ,
296
301
'--path' : self .tempdir .name
297
302
}, args )), "Non {} result for fork" .format (rc )
298
303
return RepositoryService ._current ._did_fork
@@ -344,7 +349,7 @@ def main_request_list(self, repo=None, rc=0, args={}):
344
349
assert rc == main (self .setup_args ({
345
350
'request' : True ,
346
351
'list' : True ,
347
- '<user >/<repo>' : repo ,
352
+ '<namespace >/<repo>' : repo ,
348
353
'--clone' : True ,
349
354
'--path' : self .tempdir .name
350
355
}, args )), "Non {} result for request list" .format (rc )
@@ -354,7 +359,7 @@ def main_request_fetch(self, repo=None, rc=0, args={}):
354
359
assert rc == main (self .setup_args ({
355
360
'request' : True ,
356
361
'fetch' : True ,
357
- '<user >/<repo>' : repo ,
362
+ '<namespace >/<repo>' : repo ,
358
363
'--clone' : True ,
359
364
'--path' : self .tempdir .name
360
365
}, args )), "Non {} result for request fetch" .format (rc )
@@ -364,15 +369,15 @@ def main_request_create(self, repo=None, rc=0, args={}):
364
369
assert rc == main (self .setup_args ({
365
370
'request' : True ,
366
371
'create' : True ,
367
- '<user >/<repo>' : repo ,
372
+ '<namespace >/<repo>' : repo ,
368
373
'--path' : self .tempdir .name
369
374
}, args )), "Non {} result for request create" .format (rc )
370
375
return RepositoryService ._current ._did_request_create
371
376
372
377
def main_open (self , repo = None , rc = 0 , args = {}):
373
378
assert rc == main (self .setup_args ({
374
379
'open' : True ,
375
- '<user >/<repo>' : repo ,
380
+ '<namespace >/<repo>' : repo ,
376
381
'--path' : self .tempdir .name
377
382
}, args )), "Non {} result for open" .format (rc )
378
383
return RepositoryService ._current ._did_open
@@ -388,7 +393,7 @@ def main_config(self, target, rc=0, args={}):
388
393
389
394
def main_noop (self , repo , rc = 1 , args = {}):
390
395
assert rc == main (self .setup_args ({
391
- '<user >/<repo>' : repo ,
396
+ '<namespace >/<repo>' : repo ,
392
397
'--path' : self .tempdir .name
393
398
}, args )), "Non {} result for no-action" .format (rc )
394
399
0 commit comments