1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
# |
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
# |
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
|
15
|
|
|
from st2tests.base import BaseActionAliasTestCase |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class CreateDeployment(BaseActionAliasTestCase): |
19
|
|
|
action_alias_name = "create_deployment" |
20
|
|
|
|
21
|
|
|
def test_alias_create_deployment_simple(self): |
22
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
23
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
24
|
|
|
|
25
|
|
|
command = "github deployment create st2contrib description A description" |
26
|
|
|
expected_parameters = { |
27
|
|
|
'repository': "st2contrib", |
28
|
|
|
'github_type': None, |
29
|
|
|
'ref': "master", |
30
|
|
|
'environment': "production", |
31
|
|
|
'description': "A description" |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
35
|
|
|
command=command, |
36
|
|
|
parameters=expected_parameters) |
37
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
38
|
|
|
format_strings=format_strings, |
39
|
|
|
command=command) |
40
|
|
|
|
41
|
|
|
def test_alias_create_deployment_full(self): |
42
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
43
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
44
|
|
|
|
45
|
|
|
command = "github deployment create st2contrib type online ref v1.0.0 environment staging description Another description" # NOQA |
46
|
|
|
expected_parameters = { |
47
|
|
|
'repository': "st2contrib", |
48
|
|
|
'github_type': "online", |
49
|
|
|
'ref': "v1.0.0", |
50
|
|
|
'environment': "staging", |
51
|
|
|
'description': "Another description" |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
55
|
|
|
command=command, |
56
|
|
|
parameters=expected_parameters) |
57
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
58
|
|
|
format_strings=format_strings, |
59
|
|
|
command=command) |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
class CreateRelease(BaseActionAliasTestCase): |
63
|
|
|
action_alias_name = "create_release" |
64
|
|
|
|
65
|
|
|
def test_alias_create_release_simple(self): |
66
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
67
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
68
|
|
|
|
69
|
|
|
command = "github release create st2contrib name v1.0.0 body It's a release Jim, but not as we know it!" # NOQA |
70
|
|
|
expected_parameters = { |
71
|
|
|
'repository': "st2contrib", |
72
|
|
|
'github_type': None, |
73
|
|
|
'name': "v1.0.0", |
74
|
|
|
'version_increase': None, |
75
|
|
|
'target_commitish': None, |
76
|
|
|
'body': "It's a release Jim, but not as we know it!" |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
80
|
|
|
command=command, |
81
|
|
|
parameters=expected_parameters) |
82
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
83
|
|
|
format_strings=format_strings, |
84
|
|
|
command=command) |
85
|
|
|
|
86
|
|
|
def test_alias_create_release_full(self): |
87
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
88
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
89
|
|
|
|
90
|
|
|
command = "github release create st2contrib type online version patch commit master name v1.0.0 body It's a release Jim, but not as we know it!" # NOQA |
91
|
|
|
expected_parameters = { |
92
|
|
|
'repository': "st2contrib", |
93
|
|
|
'github_type': "online", |
94
|
|
|
'version_increase': "patch", |
95
|
|
|
'target_commitish': "master", |
96
|
|
|
'name': "v1.0.0", |
97
|
|
|
'body': "It's a release Jim, but not as we know it!" |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
101
|
|
|
command=command, |
102
|
|
|
parameters=expected_parameters) |
103
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
104
|
|
|
format_strings=format_strings, |
105
|
|
|
command=command) |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
class DeploymentStatuses(BaseActionAliasTestCase): |
109
|
|
|
action_alias_name = "deployment_statuses" |
110
|
|
|
|
111
|
|
|
def test_alias_deployment_statuses_simple(self): |
112
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
113
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
114
|
|
|
|
115
|
|
|
command = "github deployment statuses st2contrib id 1" |
116
|
|
|
expected_parameters = { |
117
|
|
|
'repository': "st2contrib", |
118
|
|
|
'github_type': None, |
119
|
|
|
'deployment_id': "1", |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
123
|
|
|
command=command, |
124
|
|
|
parameters=expected_parameters) |
125
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
126
|
|
|
format_strings=format_strings, |
127
|
|
|
command=command) |
128
|
|
|
|
129
|
|
|
def test_alias_deployment_statuses_full(self): |
130
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
131
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
132
|
|
|
|
133
|
|
|
command = "github deployment statuses type online st2contrib id 1" |
134
|
|
|
expected_parameters = { |
135
|
|
|
'repository': "st2contrib", |
136
|
|
|
'github_type': "online", |
137
|
|
|
'deployment_id': "1", |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
141
|
|
|
command=command, |
142
|
|
|
parameters=expected_parameters) |
143
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
144
|
|
|
format_strings=format_strings, |
145
|
|
|
command=command) |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
class GetUser(BaseActionAliasTestCase): |
149
|
|
|
action_alias_name = "get_user" |
150
|
|
|
|
151
|
|
|
def test_alias_get_user_simple(self): |
152
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
153
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
154
|
|
|
|
155
|
|
|
command = "github get user stanley" |
156
|
|
|
expected_parameters = { |
157
|
|
|
'user': "stanley", |
158
|
|
|
'github_type': None |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
162
|
|
|
command=command, |
163
|
|
|
parameters=expected_parameters) |
164
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
165
|
|
|
format_strings=format_strings, |
166
|
|
|
command=command) |
167
|
|
|
|
168
|
|
|
def test_alias_get_user_full(self): |
169
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
170
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
171
|
|
|
|
172
|
|
|
command = "github get user type online stanley" |
173
|
|
|
expected_parameters = { |
174
|
|
|
'user': "stanley", |
175
|
|
|
'github_type': "online" |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
179
|
|
|
command=command, |
180
|
|
|
parameters=expected_parameters) |
181
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
182
|
|
|
format_strings=format_strings, |
183
|
|
|
command=command) |
184
|
|
|
|
185
|
|
|
|
186
|
|
|
class LatestRelease(BaseActionAliasTestCase): |
187
|
|
|
action_alias_name = "latest_release" |
188
|
|
|
|
189
|
|
|
def test_alias_latest_release_simple(self): |
190
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
191
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
192
|
|
|
|
193
|
|
|
command = "github release latest st2contrib" |
194
|
|
|
expected_parameters = { |
195
|
|
|
'repository': "st2contrib", |
196
|
|
|
'github_type': None |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
200
|
|
|
command=command, |
201
|
|
|
parameters=expected_parameters) |
202
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
203
|
|
|
format_strings=format_strings, |
204
|
|
|
command=command) |
205
|
|
|
|
206
|
|
|
def test_alias_latest_release_full(self): |
207
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
208
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
209
|
|
|
|
210
|
|
|
command = "github release latest type online st2contrib" |
211
|
|
|
expected_parameters = { |
212
|
|
|
'repository': "st2contrib", |
213
|
|
|
'github_type': "online" |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
217
|
|
|
command=command, |
218
|
|
|
parameters=expected_parameters) |
219
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
220
|
|
|
format_strings=format_strings, |
221
|
|
|
command=command) |
222
|
|
|
|
223
|
|
|
|
224
|
|
|
class ListRelease(BaseActionAliasTestCase): |
225
|
|
|
action_alias_name = "list_releases" |
226
|
|
|
|
227
|
|
|
def test_alias_list_release_simple(self): |
228
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
229
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
230
|
|
|
|
231
|
|
|
command = "github releases list st2contrib" |
232
|
|
|
expected_parameters = { |
233
|
|
|
'repository': "st2contrib", |
234
|
|
|
'github_type': None |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
238
|
|
|
command=command, |
239
|
|
|
parameters=expected_parameters) |
240
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
241
|
|
|
format_strings=format_strings, |
242
|
|
|
command=command) |
243
|
|
|
|
244
|
|
|
def test_alias_list_release_full(self): |
245
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
246
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
247
|
|
|
|
248
|
|
|
command = "github releases list type online st2contrib" |
249
|
|
|
expected_parameters = { |
250
|
|
|
'repository': "st2contrib", |
251
|
|
|
'github_type': "online" |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
255
|
|
|
command=command, |
256
|
|
|
parameters=expected_parameters) |
257
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
258
|
|
|
format_strings=format_strings, |
259
|
|
|
command=command) |
260
|
|
|
|
261
|
|
|
|
262
|
|
|
class StoreOauthToken(BaseActionAliasTestCase): |
263
|
|
|
action_alias_name = "store_oauth_token" |
264
|
|
|
|
265
|
|
|
def test_alias_store_oauth_token_default(self): |
266
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
267
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
268
|
|
|
|
269
|
|
|
command = "github store token foobar" |
270
|
|
|
expected_parameters = { |
271
|
|
|
'token': "foobar", |
272
|
|
|
'github_type': None |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
276
|
|
|
command=command, |
277
|
|
|
parameters=expected_parameters) |
278
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
279
|
|
|
format_strings=format_strings, |
280
|
|
|
command=command) |
281
|
|
|
|
282
|
|
|
def test_alias_store_oauth_token_online(self): |
283
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
284
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
285
|
|
|
|
286
|
|
|
command = "github store type online token foobar" |
287
|
|
|
expected_parameters = { |
288
|
|
|
'token': "foobar", |
289
|
|
|
'github_type': "online" |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
293
|
|
|
command=command, |
294
|
|
|
parameters=expected_parameters) |
295
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
296
|
|
|
format_strings=format_strings, |
297
|
|
|
command=command) |
298
|
|
|
|
299
|
|
|
def test_alias_store_oauth_token_enterprise(self): |
300
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
301
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
302
|
|
|
|
303
|
|
|
command = "github store type enterprise token foobar" |
304
|
|
|
expected_parameters = { |
305
|
|
|
'token': "foobar", |
306
|
|
|
'github_type': "enterprise" |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
310
|
|
|
command=command, |
311
|
|
|
parameters=expected_parameters) |
312
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
313
|
|
|
format_strings=format_strings, |
314
|
|
|
command=command) |
315
|
|
|
|