Merge ppa-dev-tools:set-command-basic-options into ppa-dev-tools:main
- Git
- lp:ppa-dev-tools
- set-command-basic-options
- Merge into main
Status: | Merged |
---|---|
Merge reported by: | Bryce Harrington |
Merged at revision: | 321446afc19cda9b835c1e2514605a97eb42e6f2 |
Proposed branch: | ppa-dev-tools:set-command-basic-options |
Merge into: | ppa-dev-tools:main |
Diff against target: |
462 lines (+222/-52) 6 files modified
ppa/constants.py (+2/-1) ppa/ppa_group.py (+9/-7) scripts/ppa (+120/-5) tests/helpers.py (+16/-0) tests/test_ppa_group.py (+0/-18) tests/test_scripts_ppa.py (+75/-21) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andreas Hasenack (community) | Approve | ||
Canonical Server Reporter | Pending | ||
Review via email: mp+434785@code.launchpad.net |
Commit message
Description of the change
True testing of all this stuff requires running against Launchpad, which
the unit tests don't do. Here's some example commandlines I used in my
own testing:
# Basic creation
$ ./scripts/ppa create test-set-command
# Architectures
$ ./scripts/ppa set test-set-command --architecture armhf,powerpc,s390x
$ ./scripts/ppa set test-set-command --default-
$ ./scripts/ppa set test-set-command --all-architectures
After running each command, load up the PPA webpage in the browser and
verify the settings took. I didn't run into any problems with any of
these, and would expect them to Just Work(tm) for everyone, so if you
spot any issues let me know.
Andreas Hasenack (ahasenack) : | # |
Andreas Hasenack (ahasenack) : | # |
Andreas Hasenack (ahasenack) : | # |
Andreas Hasenack (ahasenack) : | # |
Bryce Harrington (bryce) : | # |
Bryce Harrington (bryce) wrote : | # |
Bryce Harrington (bryce) wrote : | # |
Total 0 (delta 0), reused 0 (delta 0)
To git+ssh:
01d9b53..321446a main -> main
Preview Diff
1 | diff --git a/ppa/constants.py b/ppa/constants.py | |||
2 | index f6e7b01..4270392 100644 | |||
3 | --- a/ppa/constants.py | |||
4 | +++ b/ppa/constants.py | |||
5 | @@ -12,7 +12,8 @@ | |||
6 | 12 | """Global constants""" | 12 | """Global constants""" |
7 | 13 | 13 | ||
8 | 14 | ARCHES_ALL = ["amd64", "arm64", "armhf", "armel", "i386", "powerpc", "ppc64el", "s390x", "riscv64"] | 14 | ARCHES_ALL = ["amd64", "arm64", "armhf", "armel", "i386", "powerpc", "ppc64el", "s390x", "riscv64"] |
10 | 15 | ARCHES_PPA = ["amd64", "arm64", "armhf", "i386", "powerpc", "ppc64el", "s390x"] | 15 | ARCHES_PPA_DEFAULT = ["amd64", "i386"] |
11 | 16 | ARCHES_PPA_ALL = ["amd64", "arm64", "armhf", "i386", "powerpc", "ppc64el", "s390x"] | ||
12 | 16 | ARCHES_PPA_EXTRA = ["riscv64"] | 17 | ARCHES_PPA_EXTRA = ["riscv64"] |
13 | 17 | ARCHES_AUTOPKGTEST = ["amd64", "arm64", "armhf", "i386", "ppc64el", "s390x"] | 18 | ARCHES_AUTOPKGTEST = ["amd64", "arm64", "armhf", "i386", "ppc64el", "s390x"] |
14 | 18 | 19 | ||
15 | diff --git a/ppa/ppa_group.py b/ppa/ppa_group.py | |||
16 | index 622cf76..7bccbb9 100755 | |||
17 | --- a/ppa/ppa_group.py | |||
18 | +++ b/ppa/ppa_group.py | |||
19 | @@ -88,7 +88,7 @@ class PpaGroup: | |||
20 | 88 | """ | 88 | """ |
21 | 89 | return self.service.people[self.name] | 89 | return self.service.people[self.name] |
22 | 90 | 90 | ||
24 | 91 | def create(self, ppa_name='ppa', ppa_description=None): | 91 | def create(self, ppa_name='ppa', ppa_description=None, **kwargs): |
25 | 92 | """Registers a new PPA with Launchpad. | 92 | """Registers a new PPA with Launchpad. |
26 | 93 | 93 | ||
27 | 94 | If a description is not provided a default one will be generated. | 94 | If a description is not provided a default one will be generated. |
28 | @@ -100,16 +100,18 @@ class PpaGroup: | |||
29 | 100 | 100 | ||
30 | 101 | :raises PpaAlreadyExists: Raised if a PPA by this name already exists in Launchpad. | 101 | :raises PpaAlreadyExists: Raised if a PPA by this name already exists in Launchpad. |
31 | 102 | """ | 102 | """ |
36 | 103 | ppa_displayname = '' | 103 | ppa_settings = { |
37 | 104 | if ppa_description is None: | 104 | 'description': ppa_description, |
38 | 105 | ppa_description = ppa_name | 105 | 'displayname': ppa_name, |
39 | 106 | ppa_displayname = ppa_name | 106 | } |
40 | 107 | for k in kwargs.keys(): | ||
41 | 108 | ppa_settings[k] = kwargs[k] | ||
42 | 107 | 109 | ||
43 | 108 | try: | 110 | try: |
44 | 109 | self.team.createPPA( | 111 | self.team.createPPA( |
45 | 110 | name=ppa_name, | 112 | name=ppa_name, |
48 | 111 | description=ppa_description, | 113 | **ppa_settings |
49 | 112 | displayname=ppa_displayname) | 114 | ) |
50 | 113 | self.team.lp_save() | 115 | self.team.lp_save() |
51 | 114 | except BadRequest as e: | 116 | except BadRequest as e: |
52 | 115 | if "You already have a PPA" in o2str(e.content): | 117 | if "You already have a PPA" in o2str(e.content): |
53 | diff --git a/scripts/ppa b/scripts/ppa | |||
54 | index a3bad54..fbf65f2 100755 | |||
55 | --- a/scripts/ppa | |||
56 | +++ b/scripts/ppa | |||
57 | @@ -65,7 +65,8 @@ if '__file__' in globals(): | |||
58 | 65 | 65 | ||
59 | 66 | from ppa._version import __version__ | 66 | from ppa._version import __version__ |
60 | 67 | from ppa.constants import ( | 67 | from ppa.constants import ( |
62 | 68 | ARCHES_PPA, | 68 | ARCHES_PPA_ALL, |
63 | 69 | ARCHES_PPA_DEFAULT, | ||
64 | 69 | ARCHES_AUTOPKGTEST, | 70 | ARCHES_AUTOPKGTEST, |
65 | 70 | URL_AUTOPKGTEST, | 71 | URL_AUTOPKGTEST, |
66 | 71 | ) | 72 | ) |
67 | @@ -137,6 +138,69 @@ def add_global_options(parser) -> None: | |||
68 | 137 | help="Minimize output during processing") | 138 | help="Minimize output during processing") |
69 | 138 | 139 | ||
70 | 139 | 140 | ||
71 | 141 | def add_basic_config_options(parser) -> None: | ||
72 | 142 | """Adds to a parser the command line options to configure the PPA. | ||
73 | 143 | |||
74 | 144 | The config options are supported by the 'create' and 'set' command, | ||
75 | 145 | to allow configuring the PPA at creation time, or after, respectively. | ||
76 | 146 | |||
77 | 147 | These options represent what can be set as a user from the Launchpad | ||
78 | 148 | web interface. | ||
79 | 149 | """ | ||
80 | 150 | # Architectures | ||
81 | 151 | parser.add_argument( | ||
82 | 152 | '-a', '--arches', '--arch', '--architectures', | ||
83 | 153 | dest="architectures", | ||
84 | 154 | action='store', | ||
85 | 155 | default=None, | ||
86 | 156 | help="Comma-separated list of hardware architectures to use" | ||
87 | 157 | ) | ||
88 | 158 | parser.add_argument( | ||
89 | 159 | '--all-arches', '--all-architectures', | ||
90 | 160 | dest="architectures", | ||
91 | 161 | action='store_const', | ||
92 | 162 | const=','.join(ARCHES_PPA_ALL), | ||
93 | 163 | help="Enable all available architectures for the PPA" | ||
94 | 164 | ) | ||
95 | 165 | parser.add_argument( | ||
96 | 166 | '--default-arches', '--default-architectures', | ||
97 | 167 | dest="architectures", | ||
98 | 168 | action='store_const', | ||
99 | 169 | const=','.join(ARCHES_PPA_DEFAULT), | ||
100 | 170 | help="Enable all available architectures for the PPA" | ||
101 | 171 | ) | ||
102 | 172 | |||
103 | 173 | # Displayname | ||
104 | 174 | parser.add_argument( | ||
105 | 175 | '--displayname', | ||
106 | 176 | dest="displayname", | ||
107 | 177 | action='store', | ||
108 | 178 | help="A short title for the PPA's web page." | ||
109 | 179 | ) | ||
110 | 180 | |||
111 | 181 | # Description | ||
112 | 182 | parser.add_argument( | ||
113 | 183 | '--description', | ||
114 | 184 | dest="description", | ||
115 | 185 | action='store', | ||
116 | 186 | help="A short description of the archive. URLs will be rendered as links. (See also 'ppa desc'.)" | ||
117 | 187 | ) | ||
118 | 188 | |||
119 | 189 | # Enable/Disable uploading | ||
120 | 190 | parser.add_argument( | ||
121 | 191 | '--enable', | ||
122 | 192 | dest="set_enabled", | ||
123 | 193 | action='store_true', | ||
124 | 194 | help="Accept and build packages uploaded to the PPA." | ||
125 | 195 | ) | ||
126 | 196 | parser.add_argument( | ||
127 | 197 | '--disable', | ||
128 | 198 | dest="set_disabled", | ||
129 | 199 | action='store_true', | ||
130 | 200 | help="Do not accept or build packages uploaded to the PPA." | ||
131 | 201 | ) | ||
132 | 202 | |||
133 | 203 | |||
134 | 140 | def create_arg_parser(): | 204 | def create_arg_parser(): |
135 | 141 | """Sets up the command line parser object. | 205 | """Sets up the command line parser object. |
136 | 142 | 206 | ||
137 | @@ -164,9 +228,7 @@ def create_arg_parser(): | |||
138 | 164 | create_parser.add_argument('ppa_name', metavar='ppa-name', | 228 | create_parser.add_argument('ppa_name', metavar='ppa-name', |
139 | 165 | action='store', | 229 | action='store', |
140 | 166 | help="Name of the PPA to be created") | 230 | help="Name of the PPA to be created") |
144 | 167 | create_parser.add_argument('-a', '--arches', '--arch', '--architectures', | 231 | add_basic_config_options(create_parser) |
142 | 168 | dest="architectures", action='store', | ||
143 | 169 | help="Comma-separated list of hardware architectures to use") | ||
145 | 170 | 232 | ||
146 | 171 | # Desc Command | 233 | # Desc Command |
147 | 172 | desc_parser = subparser.add_parser( | 234 | desc_parser = subparser.add_parser( |
148 | @@ -207,6 +269,19 @@ def create_arg_parser(): | |||
149 | 207 | nargs='?', default='me', | 269 | nargs='?', default='me', |
150 | 208 | help="Name of the PPA to list") | 270 | help="Name of the PPA to list") |
151 | 209 | 271 | ||
152 | 272 | # Set Command | ||
153 | 273 | set_parser = subparser.add_parser( | ||
154 | 274 | 'set', | ||
155 | 275 | argument_default=argparse.SUPPRESS, | ||
156 | 276 | help='set help', | ||
157 | 277 | prog=progname, | ||
158 | 278 | ) | ||
159 | 279 | add_global_options(set_parser) | ||
160 | 280 | set_parser.add_argument('ppa_name', metavar='ppa-name', | ||
161 | 281 | action='store', | ||
162 | 282 | help="Name of the PPA to be set config values on") | ||
163 | 283 | add_basic_config_options(set_parser) | ||
164 | 284 | |||
165 | 210 | # Show Command | 285 | # Show Command |
166 | 211 | show_parser = subparser.add_parser( | 286 | show_parser = subparser.add_parser( |
167 | 212 | 'show', | 287 | 'show', |
168 | @@ -351,6 +426,13 @@ def create_config(lp, args): | |||
169 | 351 | else: | 426 | else: |
170 | 352 | warn(f"Invalid releases '{args.releases}'") | 427 | warn(f"Invalid releases '{args.releases}'") |
171 | 353 | return None | 428 | return None |
172 | 429 | elif args.command == "set": | ||
173 | 430 | if args.architectures is not None: | ||
174 | 431 | if args.architectures: | ||
175 | 432 | config['architectures'] = args.architectures.split(',') | ||
176 | 433 | else: | ||
177 | 434 | warn(f"Invalid architectures '{args.architectures}'") | ||
178 | 435 | return None | ||
179 | 354 | 436 | ||
180 | 355 | return config | 437 | return config |
181 | 356 | 438 | ||
182 | @@ -382,7 +464,7 @@ def command_create(lp, config): | |||
183 | 382 | warn("Could not determine team name") | 464 | warn("Could not determine team name") |
184 | 383 | return os.EX_USAGE | 465 | return os.EX_USAGE |
185 | 384 | 466 | ||
187 | 385 | architectures = config.get('architectures', ARCHES_PPA) | 467 | architectures = config.get('architectures', ARCHES_PPA_ALL) |
188 | 386 | 468 | ||
189 | 387 | try: | 469 | try: |
190 | 388 | if not config.get('dry_run', False): | 470 | if not config.get('dry_run', False): |
191 | @@ -519,6 +601,38 @@ def command_exists(lp, config): | |||
192 | 519 | return 1 | 601 | return 1 |
193 | 520 | 602 | ||
194 | 521 | 603 | ||
195 | 604 | def command_set(lp, config): | ||
196 | 605 | """Sets one or more properties of PPA in Launchpad. | ||
197 | 606 | |||
198 | 607 | :param Lp lp: The Launchpad wrapper object. | ||
199 | 608 | :param dict config: Configuration param:value map. | ||
200 | 609 | :rtype: int | ||
201 | 610 | :returns: Status code OK (0) on success, non-zero on error. | ||
202 | 611 | """ | ||
203 | 612 | try: | ||
204 | 613 | the_ppa = get_ppa(lp, config) | ||
205 | 614 | |||
206 | 615 | if 'architectures' in config: | ||
207 | 616 | the_ppa.set_architectures(config['architectures']) | ||
208 | 617 | |||
209 | 618 | if 'description' in config: | ||
210 | 619 | the_ppa.archive.description = config['description'] | ||
211 | 620 | |||
212 | 621 | if 'displayname' in config: | ||
213 | 622 | the_ppa.archive.displayname = config['displayname'] | ||
214 | 623 | |||
215 | 624 | return the_ppa.archive.lp_save() | ||
216 | 625 | except PpaDoesNotExist as e: | ||
217 | 626 | print(e) | ||
218 | 627 | except ValueError as e: | ||
219 | 628 | print(f"Error: {e}") | ||
220 | 629 | return os.EX_USAGE | ||
221 | 630 | except KeyboardInterrupt: | ||
222 | 631 | return 2 | ||
223 | 632 | print("Unhandled error") | ||
224 | 633 | return 1 | ||
225 | 634 | |||
226 | 635 | |||
227 | 522 | def command_show(lp, config): | 636 | def command_show(lp, config): |
228 | 523 | """Displays details about the given PPA. | 637 | """Displays details about the given PPA. |
229 | 524 | 638 | ||
230 | @@ -752,6 +866,7 @@ COMMANDS = { | |||
231 | 752 | 'desc': (command_desc, None), | 866 | 'desc': (command_desc, None), |
232 | 753 | 'destroy': (command_destroy, None), | 867 | 'destroy': (command_destroy, None), |
233 | 754 | 'list': (command_list, None), | 868 | 'list': (command_list, None), |
234 | 869 | 'set': (command_set, None), | ||
235 | 755 | 'show': (command_show, None), | 870 | 'show': (command_show, None), |
236 | 756 | 'status': (command_status, None), | 871 | 'status': (command_status, None), |
237 | 757 | 'tests': (command_tests, None), | 872 | 'tests': (command_tests, None), |
238 | diff --git a/tests/helpers.py b/tests/helpers.py | |||
239 | index 30a82bb..c6a55eb 100644 | |||
240 | --- a/tests/helpers.py | |||
241 | +++ b/tests/helpers.py | |||
242 | @@ -18,6 +18,16 @@ from ppa.ppa import Ppa | |||
243 | 18 | from ppa.ppa_group import PpaAlreadyExists | 18 | from ppa.ppa_group import PpaAlreadyExists |
244 | 19 | 19 | ||
245 | 20 | 20 | ||
246 | 21 | class ArchiveMock: | ||
247 | 22 | """A stand-in for a Launchpad Archive object.""" | ||
248 | 23 | def __init__(self, name, description): | ||
249 | 24 | self.displayname = name | ||
250 | 25 | self.description = description | ||
251 | 26 | |||
252 | 27 | def lp_save(self): | ||
253 | 28 | return True | ||
254 | 29 | |||
255 | 30 | |||
256 | 21 | class PersonMock: | 31 | class PersonMock: |
257 | 22 | """A stand-in for a Launchpad Person object.""" | 32 | """A stand-in for a Launchpad Person object.""" |
258 | 23 | def __init__(self, name): | 33 | def __init__(self, name): |
259 | @@ -32,6 +42,12 @@ class PersonMock: | |||
260 | 32 | self._ppas.append(new_ppa) | 42 | self._ppas.append(new_ppa) |
261 | 33 | return True | 43 | return True |
262 | 34 | 44 | ||
263 | 45 | def getPPAByName(self, name): | ||
264 | 46 | for ppa in self._ppas: | ||
265 | 47 | if ppa.name == name: | ||
266 | 48 | return ArchiveMock(name, ppa.description) | ||
267 | 49 | return None | ||
268 | 50 | |||
269 | 35 | def lp_save(self): | 51 | def lp_save(self): |
270 | 36 | return True | 52 | return True |
271 | 37 | 53 | ||
272 | diff --git a/tests/test_ppa_group.py b/tests/test_ppa_group.py | |||
273 | index 9bfd382..d9d83de 100644 | |||
274 | --- a/tests/test_ppa_group.py | |||
275 | +++ b/tests/test_ppa_group.py | |||
276 | @@ -69,24 +69,6 @@ def test_create_with_team(): | |||
277 | 69 | assert ppa.address == 'ppa:test_team_name/ppa_test_name' | 69 | assert ppa.address == 'ppa:test_team_name/ppa_test_name' |
278 | 70 | 70 | ||
279 | 71 | 71 | ||
280 | 72 | def test_create_for_lpbug(): | ||
281 | 73 | """Check associating a bug # when creating a PPA.""" | ||
282 | 74 | ppa_group = PpaGroup(service=LpServiceMock(), name='me') | ||
283 | 75 | lpbug = '1234567' | ||
284 | 76 | ppa = ppa_group.create('lp' + lpbug) | ||
285 | 77 | assert ppa is not None | ||
286 | 78 | assert lpbug in ppa.description | ||
287 | 79 | |||
288 | 80 | |||
289 | 81 | def test_create_for_merge_proposal(): | ||
290 | 82 | """Check associating a merge proposal when creating a PPA.""" | ||
291 | 83 | ppa_group = PpaGroup(service=LpServiceMock(), name='me') | ||
292 | 84 | version = '1.2.3-4' | ||
293 | 85 | ppa = ppa_group.create('merge.' + version) | ||
294 | 86 | assert ppa is not None | ||
295 | 87 | assert version in ppa.description | ||
296 | 88 | |||
297 | 89 | |||
298 | 90 | def test_list_ppas(): | 72 | def test_list_ppas(): |
299 | 91 | """Check listing the PPAs for a PPA group.""" | 73 | """Check listing the PPAs for a PPA group.""" |
300 | 92 | test_ppa_list = ['a', 'b', 'c', 'd'] | 74 | test_ppa_list = ['a', 'b', 'c', 'd'] |
301 | diff --git a/tests/test_scripts_ppa.py b/tests/test_scripts_ppa.py | |||
302 | index e393bd8..10acc30 100644 | |||
303 | --- a/tests/test_scripts_ppa.py | |||
304 | +++ b/tests/test_scripts_ppa.py | |||
305 | @@ -11,6 +11,7 @@ | |||
306 | 11 | """ppa command-line script tests""" | 11 | """ppa command-line script tests""" |
307 | 12 | 12 | ||
308 | 13 | import os | 13 | import os |
309 | 14 | import io | ||
310 | 14 | import sys | 15 | import sys |
311 | 15 | import types | 16 | import types |
312 | 16 | 17 | ||
313 | @@ -22,6 +23,12 @@ SCRIPT_NAME = "ppa" | |||
314 | 22 | BASE_PATH = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) | 23 | BASE_PATH = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) |
315 | 23 | sys.path.insert(0, BASE_PATH) | 24 | sys.path.insert(0, BASE_PATH) |
316 | 24 | 25 | ||
317 | 26 | from ppa.constants import ( | ||
318 | 27 | ARCHES_PPA_ALL, | ||
319 | 28 | ARCHES_PPA_DEFAULT | ||
320 | 29 | ) | ||
321 | 30 | from tests.helpers import LpServiceMock | ||
322 | 31 | |||
323 | 25 | if '.pybuild' in BASE_PATH: | 32 | if '.pybuild' in BASE_PATH: |
324 | 26 | python_version = '.'.join([str(v) for v in sys.version_info[0:2]]) | 33 | python_version = '.'.join([str(v) for v in sys.version_info[0:2]]) |
325 | 27 | scripts_path = os.path.join( | 34 | scripts_path = os.path.join( |
326 | @@ -41,7 +48,7 @@ loader.exec_module(script) | |||
327 | 41 | def fake_config(): | 48 | def fake_config(): |
328 | 42 | return { | 49 | return { |
329 | 43 | 'ppa_name': 'testing', | 50 | 'ppa_name': 'testing', |
331 | 44 | 'team_name': 'tester', | 51 | 'team_name': 'me', |
332 | 45 | 'wait_seconds': 0.1 | 52 | 'wait_seconds': 0.1 |
333 | 46 | } | 53 | } |
334 | 47 | 54 | ||
335 | @@ -145,6 +152,7 @@ def test_create_arg_parser(): | |||
336 | 145 | 'desc', | 152 | 'desc', |
337 | 146 | 'destroy', | 153 | 'destroy', |
338 | 147 | 'list', | 154 | 'list', |
339 | 155 | 'set', | ||
340 | 148 | 'show', | 156 | 'show', |
341 | 149 | 'status', | 157 | 'status', |
342 | 150 | 'tests', | 158 | 'tests', |
343 | @@ -152,36 +160,80 @@ def test_create_arg_parser(): | |||
344 | 152 | ] | 160 | ] |
345 | 153 | 161 | ||
346 | 154 | 162 | ||
349 | 155 | def test_create_arg_parser_create(): | 163 | @pytest.mark.parametrize('command', ['create', 'set']) |
350 | 156 | """Checks argument parsing for the 'create' command.""" | 164 | def test_create_arg_parser_basic_config(command): |
351 | 165 | """Checks argument parsing for the basic PPA config options. | ||
352 | 166 | |||
353 | 167 | This test covers the set of options used by 'create' and 'set' for | ||
354 | 168 | configuring various properties of the PPA's behaviors, such as | ||
355 | 169 | dependencies, publication policy, access control, etc. It does not | ||
356 | 170 | cover settings that require Launchpad administrator involvement. | ||
357 | 171 | |||
358 | 172 | The testing checks only that the options are being received and | ||
359 | 173 | registered as expected, and does not cover the processing of the | ||
360 | 174 | inputs nor the actual underlying functionality. | ||
361 | 175 | """ | ||
362 | 157 | parser = script.create_arg_parser() | 176 | parser = script.create_arg_parser() |
363 | 158 | 177 | ||
366 | 159 | # Check ppa_name | 178 | # Check command and ppa_name |
367 | 160 | args = parser.parse_args(['create', 'test-ppa']) | 179 | args = parser.parse_args([command, 'test-ppa']) |
368 | 180 | assert args.command == command | ||
369 | 161 | assert args.ppa_name == 'test-ppa' | 181 | assert args.ppa_name == 'test-ppa' |
370 | 162 | 182 | ||
371 | 163 | # Check that command args can come before or after the ppa name | 183 | # Check that command args can come before or after the ppa name |
373 | 164 | args = parser.parse_args(['create', 'test-ppa', '-a', 'x']) | 184 | args = parser.parse_args([command, 'test-ppa', '-a', 'x']) |
374 | 165 | assert args.architectures == 'x' | 185 | assert args.architectures == 'x' |
375 | 166 | args.architectures = None | 186 | args.architectures = None |
377 | 167 | args = parser.parse_args(['create', '-a', 'x', 'test-ppa']) | 187 | args = parser.parse_args([command, '-a', 'x', 'test-ppa']) |
378 | 168 | assert args.architectures == 'x' | 188 | assert args.architectures == 'x' |
379 | 169 | args.architectures = None | 189 | args.architectures = None |
380 | 170 | 190 | ||
381 | 191 | # Check --all-arches and --default-arches | ||
382 | 192 | args = parser.parse_args([command, 'test-ppa', '--all-arches']) | ||
383 | 193 | assert args.architectures == ','.join(ARCHES_PPA_ALL) | ||
384 | 194 | args.architectures = None | ||
385 | 195 | args = parser.parse_args([command, 'test-ppa', '--all-architectures']) | ||
386 | 196 | assert args.architectures == ','.join(ARCHES_PPA_ALL) | ||
387 | 197 | args.architectures = None | ||
388 | 198 | args = parser.parse_args([command, 'test-ppa', '--default-arches']) | ||
389 | 199 | assert args.architectures == ','.join(ARCHES_PPA_DEFAULT) | ||
390 | 200 | args.architectures = None | ||
391 | 201 | args = parser.parse_args([command, 'test-ppa', '--default-architectures']) | ||
392 | 202 | assert args.architectures == ','.join(ARCHES_PPA_DEFAULT) | ||
393 | 203 | args.architectures = None | ||
394 | 204 | |||
395 | 171 | # Check -a, --arch, --arches, --architectures | 205 | # Check -a, --arch, --arches, --architectures |
397 | 172 | args = parser.parse_args(['create', 'test-ppa', '-a', 'x']) | 206 | args = parser.parse_args([command, 'test-ppa', '-a', 'x']) |
398 | 173 | assert args.architectures == 'x' | 207 | assert args.architectures == 'x' |
399 | 174 | args.architectures = None | 208 | args.architectures = None |
401 | 175 | args = parser.parse_args(['create', 'test-ppa', '--arch', 'x']) | 209 | args = parser.parse_args([command, 'test-ppa', '--arch', 'x']) |
402 | 176 | assert args.architectures == 'x' | 210 | assert args.architectures == 'x' |
403 | 177 | args.architectures = None | 211 | args.architectures = None |
405 | 178 | args = parser.parse_args(['create', 'test-ppa', '--arches', 'x']) | 212 | args = parser.parse_args([command, 'test-ppa', '--arches', 'x']) |
406 | 179 | assert args.architectures == 'x' | 213 | assert args.architectures == 'x' |
407 | 180 | args.architectures = None | 214 | args.architectures = None |
409 | 181 | args = parser.parse_args(['create', 'test-ppa', '--architectures', 'a,b,c']) | 215 | args = parser.parse_args([command, 'test-ppa', '--architectures', 'a,b,c']) |
410 | 182 | assert args.architectures == 'a,b,c' | 216 | assert args.architectures == 'a,b,c' |
411 | 183 | args.architectures = None | 217 | args.architectures = None |
412 | 184 | 218 | ||
413 | 219 | # Check --displayname | ||
414 | 220 | args = parser.parse_args([command, 'test-ppa', '--displayname', 'x']) | ||
415 | 221 | assert args.displayname == 'x' | ||
416 | 222 | args.displayname = None | ||
417 | 223 | |||
418 | 224 | # Check --description | ||
419 | 225 | args = parser.parse_args([command, 'test-ppa', '--description', 'x']) | ||
420 | 226 | assert args.description == 'x' | ||
421 | 227 | args.description = None | ||
422 | 228 | |||
423 | 229 | # Check --enable / -D|--disable | ||
424 | 230 | args = parser.parse_args([command, 'test-ppa', '--enable']) | ||
425 | 231 | assert args.set_enabled is True | ||
426 | 232 | args.set_enabled = False | ||
427 | 233 | args = parser.parse_args([command, 'test-ppa', '--disable']) | ||
428 | 234 | assert args.set_disabled is True | ||
429 | 235 | args.set_disabled = False | ||
430 | 236 | |||
431 | 185 | 237 | ||
432 | 186 | def test_create_arg_parser_show(): | 238 | def test_create_arg_parser_show(): |
433 | 187 | """Checks argument parsing for the 'show' command.""" | 239 | """Checks argument parsing for the 'show' command.""" |
434 | @@ -312,16 +364,18 @@ def test_create_config(): | |||
435 | 312 | pass | 364 | pass |
436 | 313 | 365 | ||
437 | 314 | 366 | ||
448 | 315 | @pytest.mark.xfail(reason="Unimplemented") | 367 | def test_command_create(fake_config, monkeypatch): |
449 | 316 | def test_command_create(fake_config): | 368 | lp = LpServiceMock() |
450 | 317 | assert script.command_create(fake_config) == 0 | 369 | monkeypatch.setattr("sys.stdin", io.StringIO('test description')) |
451 | 318 | 370 | assert script.command_create(lp, fake_config) == 0 | |
452 | 319 | # TODO: Specify a ppa_name and verify it gets used properly | 371 | |
453 | 320 | # TODO: Specify a team name | 372 | the_ppa = lp.me.getPPAByName(fake_config['ppa_name']) |
454 | 321 | # TODO: Verify if no team name specified, the lp_user is used | 373 | |
455 | 322 | # instead | 374 | # Check basic attributes (further coverage is in test_ppa_group.py) |
456 | 323 | # TODO: Verify the ppa_address is set as expected | 375 | assert the_ppa.displayname == fake_config['ppa_name'] |
457 | 324 | pass | 376 | assert the_ppa.description == 'test description' |
458 | 377 | |||
459 | 378 | # TODO: Check processors | ||
460 | 325 | 379 | ||
461 | 326 | 380 | ||
462 | 327 | @pytest.mark.xfail(reason="Unimplemented") | 381 | @pytest.mark.xfail(reason="Unimplemented") |
Fixed help text for --disable