Merge ppa-dev-tools:make-check-fixes into ppa-dev-tools:main
- Git
- lp:ppa-dev-tools
- make-check-fixes
- Merge into main
Proposed by
Bryce Harrington
Status: | Merged |
---|---|
Merged at revision: | c1451af3a7d727b1499275858e4c24f49e82321e |
Proposed branch: | ppa-dev-tools:make-check-fixes |
Merge into: | ppa-dev-tools:main |
Diff against target: |
817 lines (+132/-82) 14 files modified
ppa/debug.py (+3/-0) ppa/job.py (+9/-6) ppa/lp.py (+4/-4) ppa/ppa.py (+11/-7) ppa/ppa_group.py (+5/-3) ppa/processes.py (+8/-6) ppa/result.py (+1/-2) ppa/subtest.py (+2/-3) ppa/text.py (+18/-13) tests/test_lp.py (+11/-3) tests/test_ppa.py (+3/-3) tests/test_ppa_group.py (+15/-7) tests/test_scripts_ppa.py (+40/-22) tests/test_version.py (+2/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christian Ehrhardt (community) | Approve | ||
Canonical Server | Pending | ||
Canonical Server Reporter | Pending | ||
Review via email:
|
Commit message
Description of the change
Cleanup to prep for 0.2 release.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Bryce Harrington (bryce) wrote : | # |
Excellent, thanks
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/ppa/debug.py b/ppa/debug.py | |||
2 | index 8339e73..009ead4 100644 | |||
3 | --- a/ppa/debug.py | |||
4 | +++ b/ppa/debug.py | |||
5 | @@ -13,6 +13,7 @@ import pprint | |||
6 | 13 | 13 | ||
7 | 14 | DEBUGGING = False | 14 | DEBUGGING = False |
8 | 15 | 15 | ||
9 | 16 | |||
10 | 16 | def dbg(msg): | 17 | def dbg(msg): |
11 | 17 | """Prints information if debugging is enabled""" | 18 | """Prints information if debugging is enabled""" |
12 | 18 | if DEBUGGING: | 19 | if DEBUGGING: |
13 | @@ -21,10 +22,12 @@ def dbg(msg): | |||
14 | 21 | else: | 22 | else: |
15 | 22 | pprint.pprint(msg) | 23 | pprint.pprint(msg) |
16 | 23 | 24 | ||
17 | 25 | |||
18 | 24 | def warn(msg): | 26 | def warn(msg): |
19 | 25 | """Prints message to stderr""" | 27 | """Prints message to stderr""" |
20 | 26 | sys.stderr.write("Warning: {}\n".format(msg)) | 28 | sys.stderr.write("Warning: {}\n".format(msg)) |
21 | 27 | 29 | ||
22 | 30 | |||
23 | 28 | def die(msg, code=1): | 31 | def die(msg, code=1): |
24 | 29 | """Prints message to stderr and exits with given code""" | 32 | """Prints message to stderr and exits with given code""" |
25 | 30 | sys.stderr.write("Error: {}\n".format(msg)) | 33 | sys.stderr.write("Error: {}\n".format(msg)) |
26 | diff --git a/ppa/job.py b/ppa/job.py | |||
27 | index 2ae06ba..91f015c 100755 | |||
28 | --- a/ppa/job.py | |||
29 | +++ b/ppa/job.py | |||
30 | @@ -148,9 +148,9 @@ def show_running(jobs): | |||
31 | 148 | if n == 1: | 148 | if n == 1: |
32 | 149 | print("Running:") | 149 | print("Running:") |
33 | 150 | ppa_str = ','.join(e.ppas) | 150 | ppa_str = ','.join(e.ppas) |
35 | 151 | trigger_str = ','.join(e.triggers) | 151 | trig_str = ','.join(e.triggers) |
36 | 152 | print(rformat % ("time", "pkg", "release", "arch", "ppa", "trigger")) | 152 | print(rformat % ("time", "pkg", "release", "arch", "ppa", "trigger")) |
38 | 153 | print(rformat % (str(e.submit_time), e.source_package, e.series, e.arch, ppa_str, trigger_str)) | 153 | print(rformat % (str(e.submit_time), e.source_package, e.series, e.arch, ppa_str, trig_str)) |
39 | 154 | if n == 0: | 154 | if n == 0: |
40 | 155 | print("Running: (none)") | 155 | print("Running: (none)") |
41 | 156 | 156 | ||
42 | @@ -164,7 +164,10 @@ def show_waiting(jobs): | |||
43 | 164 | if n == 1: | 164 | if n == 1: |
44 | 165 | print("Waiting:") | 165 | print("Waiting:") |
45 | 166 | print(rformat % ("Q-num", "pkg", "release", "arch", "ppa", "trigger")) | 166 | print(rformat % ("Q-num", "pkg", "release", "arch", "ppa", "trigger")) |
47 | 167 | print(rformat % (e.number, e.source_package, e.series, e.arch, ','.join(e.ppas), ','.join(e.triggers))) | 167 | |
48 | 168 | ppa_str = ','.join(e.ppas) | ||
49 | 169 | trig_str = ','.join(e.triggers) | ||
50 | 170 | print(rformat % (e.number, e.source_package, e.series, e.arch, ppa_str, trig_str)) | ||
51 | 168 | if n == 0: | 171 | if n == 0: |
52 | 169 | print("Waiting: (none)") | 172 | print("Waiting: (none)") |
53 | 170 | 173 | ||
54 | @@ -178,8 +181,8 @@ if __name__ == "__main__": | |||
55 | 178 | root_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) | 181 | root_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) |
56 | 179 | jobinfo = { | 182 | jobinfo = { |
57 | 180 | 'triggers': ['a/1', 'b/2.1', 'c/3.2.1'], | 183 | 'triggers': ['a/1', 'b/2.1', 'c/3.2.1'], |
60 | 181 | 'ppas': ['ppa:me/myppa'], | 184 | 'ppas': ['ppa:me/myppa'] |
61 | 182 | } | 185 | } |
62 | 183 | job_1 = Job( | 186 | job_1 = Job( |
63 | 184 | number=0, | 187 | number=0, |
64 | 185 | submit_time='time', | 188 | submit_time='time', |
65 | @@ -188,7 +191,7 @@ if __name__ == "__main__": | |||
66 | 188 | arch='amd64', | 191 | arch='amd64', |
67 | 189 | triggers=jobinfo.get('triggers', None), | 192 | triggers=jobinfo.get('triggers', None), |
68 | 190 | ppas=jobinfo.get('ppas', None) | 193 | ppas=jobinfo.get('ppas', None) |
70 | 191 | ) | 194 | ) |
71 | 192 | print(job_1) | 195 | print(job_1) |
72 | 193 | print(f"triggers: {job_1.triggers}") | 196 | print(f"triggers: {job_1.triggers}") |
73 | 194 | print(f"ppas: {job_1.ppas}") | 197 | print(f"ppas: {job_1.ppas}") |
74 | diff --git a/ppa/lp.py b/ppa/lp.py | |||
75 | index c3ebaac..1762345 100644 | |||
76 | --- a/ppa/lp.py | |||
77 | +++ b/ppa/lp.py | |||
78 | @@ -14,12 +14,12 @@ | |||
79 | 14 | High level wrapper object for Launchpad's API | 14 | High level wrapper object for Launchpad's API |
80 | 15 | """ | 15 | """ |
81 | 16 | 16 | ||
82 | 17 | from os.path import join | ||
83 | 18 | from contextlib import suppress | 17 | from contextlib import suppress |
84 | 19 | from functools import lru_cache | 18 | from functools import lru_cache |
85 | 20 | 19 | ||
86 | 21 | from launchpadlib.launchpad import Launchpad | 20 | from launchpadlib.launchpad import Launchpad |
87 | 22 | 21 | ||
88 | 22 | |||
89 | 23 | class Lp: | 23 | class Lp: |
90 | 24 | """ | 24 | """ |
91 | 25 | This class wrappers the Launchpadlib service to cache object queries | 25 | This class wrappers the Launchpadlib service to cache object queries |
92 | @@ -32,8 +32,8 @@ class Lp: | |||
93 | 32 | itself is passed directly to the Launchpadlib object, so the entire | 32 | itself is passed directly to the Launchpadlib object, so the entire |
94 | 33 | API is available in exactly the same way. | 33 | API is available in exactly the same way. |
95 | 34 | """ | 34 | """ |
98 | 35 | ROOT_URL = 'https://launchpad.net/' | 35 | ROOT_URL = 'https://launchpad.net/' |
99 | 36 | API_ROOT_URL = 'https://api.launchpad.net/devel/' | 36 | API_ROOT_URL = 'https://api.launchpad.net/devel/' |
100 | 37 | BUGS_ROOT_URL = 'https://bugs.launchpad.net/' | 37 | BUGS_ROOT_URL = 'https://bugs.launchpad.net/' |
101 | 38 | CODE_ROOT_URL = 'https://code.launchpad.net/' | 38 | CODE_ROOT_URL = 'https://code.launchpad.net/' |
102 | 39 | 39 | ||
103 | @@ -68,7 +68,7 @@ class Lp: | |||
104 | 68 | 68 | ||
105 | 69 | def __getattr__(self, attr): | 69 | def __getattr__(self, attr): |
106 | 70 | """Wrap launchpadlib so tightly you can't tell the difference.""" | 70 | """Wrap launchpadlib so tightly you can't tell the difference.""" |
108 | 71 | assert not attr.startswith('_'), "Can't getattr for %s" %(attr) | 71 | assert not attr.startswith('_'), f"Can't getattr for {attr}" |
109 | 72 | instance = super(Lp, self).__getattribute__('_instance') | 72 | instance = super(Lp, self).__getattribute__('_instance') |
110 | 73 | return getattr(instance, attr) | 73 | return getattr(instance, attr) |
111 | 74 | 74 | ||
112 | diff --git a/ppa/ppa.py b/ppa/ppa.py | |||
113 | index 6f744a4..763ed7f 100755 | |||
114 | --- a/ppa/ppa.py | |||
115 | +++ b/ppa/ppa.py | |||
116 | @@ -44,7 +44,7 @@ def ppa_address_split(ppa_address, default_team='me'): | |||
117 | 44 | if ppa_address.startswith('ppa:'): | 44 | if ppa_address.startswith('ppa:'): |
118 | 45 | if '/' not in ppa_address: | 45 | if '/' not in ppa_address: |
119 | 46 | return (None, None) | 46 | return (None, None) |
121 | 47 | rem = ppa_address.split('ppa:',1)[1] | 47 | rem = ppa_address.split('ppa:', 1)[1] |
122 | 48 | team_name = rem.split('/', 1)[0] | 48 | team_name = rem.split('/', 1)[0] |
123 | 49 | ppa_name = rem.split('/', 1)[1] | 49 | ppa_name = rem.split('/', 1)[1] |
124 | 50 | else: | 50 | else: |
125 | @@ -193,7 +193,7 @@ class Ppa: | |||
126 | 193 | :returns: List of architecture names, or None on error. | 193 | :returns: List of architecture names, or None on error. |
127 | 194 | """ | 194 | """ |
128 | 195 | try: | 195 | try: |
130 | 196 | return [ proc.name for proc in self.archive.processors ] | 196 | return [proc.name for proc in self.archive.processors] |
131 | 197 | except PpaDoesNotExist as e: | 197 | except PpaDoesNotExist as e: |
132 | 198 | print(e) | 198 | print(e) |
133 | 199 | return None | 199 | return None |
134 | @@ -208,7 +208,7 @@ class Ppa: | |||
135 | 208 | :returns: List of architecture names, or None on error. | 208 | :returns: List of architecture names, or None on error. |
136 | 209 | """ | 209 | """ |
137 | 210 | uri_base = "https://api.launchpad.net/devel/+processors/{}" | 210 | uri_base = "https://api.launchpad.net/devel/+processors/{}" |
139 | 211 | procs = [ uri_base.format(arch) for arch in architectures ] | 211 | procs = [uri_base.format(arch) for arch in architectures] |
140 | 212 | try: | 212 | try: |
141 | 213 | self.archive.setProcessors(processors=procs) | 213 | self.archive.setProcessors(processors=procs) |
142 | 214 | return True | 214 | return True |
143 | @@ -225,7 +225,7 @@ class Ppa: | |||
144 | 225 | :rtype: list[binary_package_publishing_history] | 225 | :rtype: list[binary_package_publishing_history] |
145 | 226 | :returns: List of binaries, or None on error | 226 | :returns: List of binaries, or None on error |
146 | 227 | """ | 227 | """ |
148 | 228 | if distro == None and series == None and arch == None: | 228 | if distro is None and series is None and arch is None: |
149 | 229 | try: | 229 | try: |
150 | 230 | return self.archive.getPublishedBinaries() | 230 | return self.archive.getPublishedBinaries() |
151 | 231 | except PpaDoesNotExist as e: | 231 | except PpaDoesNotExist as e: |
152 | @@ -323,7 +323,9 @@ class Ppa: | |||
153 | 323 | published_builds[binary_publication.build_link] = binary_publication | 323 | published_builds[binary_publication.build_link] = binary_publication |
154 | 324 | 324 | ||
155 | 325 | retval = False | 325 | retval = False |
157 | 326 | num_builds_waiting = len(required_builds) - len(pending_publication_builds) - len(published_builds) | 326 | num_builds_waiting = ( |
158 | 327 | len(required_builds) - len(pending_publication_builds) - len(published_builds) | ||
159 | 328 | ) | ||
160 | 327 | if num_builds_waiting != 0: | 329 | if num_builds_waiting != 0: |
161 | 328 | num_build_failures = 0 | 330 | num_build_failures = 0 |
162 | 329 | builds_waiting_output = '' | 331 | builds_waiting_output = '' |
163 | @@ -353,12 +355,14 @@ class Ppa: | |||
164 | 353 | retval = True | 355 | retval = True |
165 | 354 | 356 | ||
166 | 355 | if len(pending_publication_builds) != 0: | 357 | if len(pending_publication_builds) != 0: |
168 | 356 | print("* Still waiting on {} build publications:".format(len(pending_publication_builds))) | 358 | num = len(pending_publication_builds) |
169 | 359 | print(f"* Still waiting on {num} build publications:") | ||
170 | 357 | for pub in pending_publication_builds.values(): | 360 | for pub in pending_publication_builds.values(): |
171 | 358 | print(" - {}".format(pub.display_name)) | 361 | print(" - {}".format(pub.display_name)) |
172 | 359 | retval = True | 362 | retval = True |
173 | 360 | if len(pending_publication_sources) != 0: | 363 | if len(pending_publication_sources) != 0: |
175 | 361 | print("* Still waiting on {} source publications:".format(len(pending_publication_sources))) | 364 | num = len(pending_publication_sources) |
176 | 365 | print(f"* Still waiting on {num} source publications:") | ||
177 | 362 | for pub in pending_publication_sources.values(): | 366 | for pub in pending_publication_sources.values(): |
178 | 363 | print(" - {}".format(pub.display_name)) | 367 | print(" - {}".format(pub.display_name)) |
179 | 364 | retval = True | 368 | retval = True |
180 | diff --git a/ppa/ppa_group.py b/ppa/ppa_group.py | |||
181 | index cb769ad..1a9c8b7 100755 | |||
182 | --- a/ppa/ppa_group.py | |||
183 | +++ b/ppa/ppa_group.py | |||
184 | @@ -14,6 +14,7 @@ from .text import o2str | |||
185 | 14 | from functools import lru_cache | 14 | from functools import lru_cache |
186 | 15 | from lazr.restfulclient.errors import BadRequest | 15 | from lazr.restfulclient.errors import BadRequest |
187 | 16 | 16 | ||
188 | 17 | |||
189 | 17 | class PpaAlreadyExists(BaseException): | 18 | class PpaAlreadyExists(BaseException): |
190 | 18 | '''Exception indicating a PPA operation could not be performed''' | 19 | '''Exception indicating a PPA operation could not be performed''' |
191 | 19 | 20 | ||
192 | @@ -34,7 +35,8 @@ class PpaAlreadyExists(BaseException): | |||
193 | 34 | if self.message: | 35 | if self.message: |
194 | 35 | return self.message | 36 | return self.message |
195 | 36 | elif self.ppa_name: | 37 | elif self.ppa_name: |
197 | 37 | return "The PPA %s already exists" %(self.ppa_name) | 38 | return f"The PPA {self.ppa_name} already exists" |
198 | 39 | |||
199 | 38 | 40 | ||
200 | 39 | class PpaGroup: | 41 | class PpaGroup: |
201 | 40 | """Represents a team or person that owns one or more PPAs. | 42 | """Represents a team or person that owns one or more PPAs. |
202 | @@ -58,7 +60,7 @@ class PpaGroup: | |||
203 | 58 | 60 | ||
204 | 59 | def __repr__(self): | 61 | def __repr__(self): |
205 | 60 | return (f'{self.__class__.__name__}(' | 62 | return (f'{self.__class__.__name__}(' |
207 | 61 | f'service={self.service!r}, name={self.name!r})') | 63 | f'service={self.service!r}, name={self.name!r})') |
208 | 62 | 64 | ||
209 | 63 | def __str__(self): | 65 | def __str__(self): |
210 | 64 | return 'tbd' | 66 | return 'tbd' |
211 | @@ -91,7 +93,7 @@ class PpaGroup: | |||
212 | 91 | ppa_displayname = ppa_name | 93 | ppa_displayname = ppa_name |
213 | 92 | 94 | ||
214 | 93 | try: | 95 | try: |
216 | 94 | results = self.team.createPPA( | 96 | self.team.createPPA( |
217 | 95 | name=ppa_name, | 97 | name=ppa_name, |
218 | 96 | description=ppa_description, | 98 | description=ppa_description, |
219 | 97 | displayname=ppa_displayname) | 99 | displayname=ppa_displayname) |
220 | diff --git a/ppa/processes.py b/ppa/processes.py | |||
221 | index e008c0c..5f54e39 100644 | |||
222 | --- a/ppa/processes.py | |||
223 | +++ b/ppa/processes.py | |||
224 | @@ -28,7 +28,6 @@ from subprocess import (Popen, PIPE) | |||
225 | 28 | from .debug import dbg | 28 | from .debug import dbg |
226 | 29 | from .text import o2str | 29 | from .text import o2str |
227 | 30 | 30 | ||
228 | 31 | # TODO: Integrate use of dbg and ERR from utils | ||
229 | 32 | 31 | ||
230 | 33 | class ReturnCode(BaseException): | 32 | class ReturnCode(BaseException): |
231 | 34 | def __init__(self, code, errors=None): | 33 | def __init__(self, code, errors=None): |
232 | @@ -40,11 +39,12 @@ class ReturnCode(BaseException): | |||
233 | 40 | 39 | ||
234 | 41 | def __str__(self): | 40 | def __str__(self): |
235 | 42 | text = '\n'.join(self.errors) | 41 | text = '\n'.join(self.errors) |
237 | 43 | return "%sReturned error code %d" %(text, self.code) | 42 | return f"{text}Returned error code {self.code}" |
238 | 43 | |||
239 | 44 | 44 | ||
240 | 45 | def shell(command, in_text=None): | 45 | def shell(command, in_text=None): |
241 | 46 | """Executes command in a shell, returns stdout, raises exception on error""" | 46 | """Executes command in a shell, returns stdout, raises exception on error""" |
243 | 47 | dbg("shell: %s" %(command)) | 47 | dbg(f"shell: {command}") |
244 | 48 | if in_text: | 48 | if in_text: |
245 | 49 | p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, stdin=PIPE) | 49 | p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, stdin=PIPE) |
246 | 50 | output, errors = p.communicate(input=in_text) | 50 | output, errors = p.communicate(input=in_text) |
247 | @@ -55,14 +55,15 @@ def shell(command, in_text=None): | |||
248 | 55 | raise ReturnCode(p.returncode, o2str(errors)) | 55 | raise ReturnCode(p.returncode, o2str(errors)) |
249 | 56 | return o2str(output) | 56 | return o2str(output) |
250 | 57 | 57 | ||
251 | 58 | |||
252 | 58 | def execute(command, in_text=None): | 59 | def execute(command, in_text=None): |
253 | 59 | """Executes command, returns stdout; prints errors to stderr""" | 60 | """Executes command, returns stdout; prints errors to stderr""" |
255 | 60 | dbg("execute: `%s`" %(command)) | 61 | dbg(f"execute: `{command}`") |
256 | 61 | if in_text is None: | 62 | if in_text is None: |
257 | 62 | p = Popen(command, shell=False, stdout=PIPE, stderr=PIPE) | 63 | p = Popen(command, shell=False, stdout=PIPE, stderr=PIPE) |
258 | 63 | else: | 64 | else: |
259 | 64 | p = Popen(command, shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE) | 65 | p = Popen(command, shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE) |
261 | 65 | dbg("execute: polling (%s)..." %(in_text)) | 66 | dbg(f"execute: polling ({in_text})...") |
262 | 66 | while p.poll() is None and p.stdin is not None: | 67 | while p.poll() is None and p.stdin is not None: |
263 | 67 | dbg("execute: Sending to process stdin") | 68 | dbg("execute: Sending to process stdin") |
264 | 68 | p.stdin.write(in_text) | 69 | p.stdin.write(in_text) |
265 | @@ -70,10 +71,11 @@ def execute(command, in_text=None): | |||
266 | 70 | sleep(0.01) | 71 | sleep(0.01) |
267 | 71 | output = p.stdout.read() | 72 | output = p.stdout.read() |
268 | 72 | if p.returncode: | 73 | if p.returncode: |
270 | 73 | dbg("Received return code %d" %(p.returncode)) | 74 | dbg(f"Received return code {p.returncode}") |
271 | 74 | raise ReturnCode(p.returncode, p.stderr.readlines()) | 75 | raise ReturnCode(p.returncode, p.stderr.readlines()) |
272 | 75 | return o2str(output) | 76 | return o2str(output) |
273 | 76 | 77 | ||
274 | 78 | |||
275 | 77 | def execute_with_input(command, in_text): | 79 | def execute_with_input(command, in_text): |
276 | 78 | """Executes command, passing in_text to stdin if provided""" | 80 | """Executes command, passing in_text to stdin if provided""" |
277 | 79 | execute(command, in_text) | 81 | execute(command, in_text) |
278 | diff --git a/ppa/result.py b/ppa/result.py | |||
279 | index 7a2ca5a..4f4aadd 100755 | |||
280 | --- a/ppa/result.py | |||
281 | +++ b/ppa/result.py | |||
282 | @@ -30,7 +30,7 @@ class Result: | |||
283 | 30 | VALUES = { | 30 | VALUES = { |
284 | 31 | 'PASS': "✅", | 31 | 'PASS': "✅", |
285 | 32 | 'FAIL': "❌", | 32 | 'FAIL': "❌", |
287 | 33 | 'BAD': "⛔", | 33 | 'BAD': "⛔" |
288 | 34 | } | 34 | } |
289 | 35 | 35 | ||
290 | 36 | def __init__(self, url, time, series, arch, source): | 36 | def __init__(self, url, time, series, arch, source): |
291 | @@ -145,7 +145,6 @@ class Result: | |||
292 | 145 | package, version = t.split('/', 1) | 145 | package, version = t.split('/', 1) |
293 | 146 | yield Trigger(package, version, arch=self.arch, series=self.series) | 146 | yield Trigger(package, version, arch=self.arch, series=self.series) |
294 | 147 | 147 | ||
295 | 148 | |||
296 | 149 | @lru_cache | 148 | @lru_cache |
297 | 150 | def get_subtests(self, name=None) -> Iterator[Subtest]: | 149 | def get_subtests(self, name=None) -> Iterator[Subtest]: |
298 | 151 | """Provides list of Subtests that were run for this Result. | 150 | """Provides list of Subtests that were run for this Result. |
299 | diff --git a/ppa/subtest.py b/ppa/subtest.py | |||
300 | index c63dda6..90134b8 100755 | |||
301 | --- a/ppa/subtest.py | |||
302 | +++ b/ppa/subtest.py | |||
303 | @@ -12,7 +12,6 @@ | |||
304 | 12 | """An individual DEP8 test run""" | 12 | """An individual DEP8 test run""" |
305 | 13 | 13 | ||
306 | 14 | from functools import cached_property | 14 | from functools import cached_property |
307 | 15 | from typing import List, Iterator | ||
308 | 16 | 15 | ||
309 | 17 | 16 | ||
310 | 18 | class Subtest: | 17 | class Subtest: |
311 | @@ -25,9 +24,9 @@ class Subtest: | |||
312 | 25 | 'PASS': "🟩", | 24 | 'PASS': "🟩", |
313 | 26 | 'SKIP': "🟧", | 25 | 'SKIP': "🟧", |
314 | 27 | 'FAIL': "🟥", | 26 | 'FAIL': "🟥", |
316 | 28 | 'BAD': "⛔", | 27 | 'BAD': "⛔", |
317 | 29 | 'UNKNOWN': "⚪" | 28 | 'UNKNOWN': "⚪" |
319 | 30 | } | 29 | } |
320 | 31 | 30 | ||
321 | 32 | def __init__(self, line): | 31 | def __init__(self, line): |
322 | 33 | """Initializes a new Subtext object. | 32 | """Initializes a new Subtext object. |
323 | diff --git a/ppa/text.py b/ppa/text.py | |||
324 | index fb8c558..b1e1453 100644 | |||
325 | --- a/ppa/text.py | |||
326 | +++ b/ppa/text.py | |||
327 | @@ -24,9 +24,11 @@ | |||
328 | 24 | 24 | ||
329 | 25 | '''Routines to encode or convert to and from text''' | 25 | '''Routines to encode or convert to and from text''' |
330 | 26 | 26 | ||
332 | 27 | from decimal import Decimal | 27 | import sys |
333 | 28 | from decimal import Decimal | ||
334 | 28 | from functools import lru_cache | 29 | from functools import lru_cache |
335 | 29 | 30 | ||
336 | 31 | |||
337 | 30 | @lru_cache | 32 | @lru_cache |
338 | 31 | def quote(msg): | 33 | def quote(msg): |
339 | 32 | """ | 34 | """ |
340 | @@ -39,13 +41,14 @@ def quote(msg): | |||
341 | 39 | msg = msg.replace('>', '>') | 41 | msg = msg.replace('>', '>') |
342 | 40 | return msg | 42 | return msg |
343 | 41 | 43 | ||
344 | 44 | |||
345 | 42 | @lru_cache | 45 | @lru_cache |
346 | 43 | def o2str(obj): | 46 | def o2str(obj): |
347 | 44 | """ | 47 | """ |
348 | 45 | Convert a unicode, decimal.Decimal, datetime object, etc. to a str. | 48 | Convert a unicode, decimal.Decimal, datetime object, etc. to a str. |
349 | 46 | Converts lists and tuples of objects into lists of strings. | 49 | Converts lists and tuples of objects into lists of strings. |
350 | 47 | """ | 50 | """ |
352 | 48 | retval = None | 51 | |
353 | 49 | if type(obj) == str: | 52 | if type(obj) == str: |
354 | 50 | return obj | 53 | return obj |
355 | 51 | elif type(obj) == bytes: | 54 | elif type(obj) == bytes: |
356 | @@ -60,9 +63,10 @@ def o2str(obj): | |||
357 | 60 | elif str(type(obj)) == "<type 'datetime.datetime'>": | 63 | elif str(type(obj)) == "<type 'datetime.datetime'>": |
358 | 61 | return obj.ctime() | 64 | return obj.ctime() |
359 | 62 | else: | 65 | else: |
361 | 63 | #print str(type(obj)) | 66 | # print str(type(obj)) |
362 | 64 | return obj | 67 | return obj |
363 | 65 | 68 | ||
364 | 69 | |||
365 | 66 | @lru_cache | 70 | @lru_cache |
366 | 67 | def to_bool(value): | 71 | def to_bool(value): |
367 | 68 | """ | 72 | """ |
368 | @@ -70,14 +74,15 @@ def to_bool(value): | |||
369 | 70 | Possible True values: 1, True, '1', 'TRue', 'yes', 'y', 't' | 74 | Possible True values: 1, True, '1', 'TRue', 'yes', 'y', 't' |
370 | 71 | Possible False values: 0, False, None, [], {}, '', '0', 'faLse', 'no', 'n', 'f', 0.0 | 75 | Possible False values: 0, False, None, [], {}, '', '0', 'faLse', 'no', 'n', 'f', 0.0 |
371 | 72 | """ | 76 | """ |
374 | 73 | if type(value) == type(''): | 77 | if isinstance(value, str): |
375 | 74 | if value.lower() in ("yes", "y", "true", "t", "1"): | 78 | if value.lower() in ("yes", "y", "true", "t", "1"): |
376 | 75 | return True | 79 | return True |
378 | 76 | if value.lower() in ("no", "n", "false", "f", "0", "none", ""): | 80 | if value.lower() in ("no", "n", "false", "f", "0", "none", ""): |
379 | 77 | return False | 81 | return False |
380 | 78 | raise Exception('Invalid value for boolean conversion: ' + value) | 82 | raise Exception('Invalid value for boolean conversion: ' + value) |
381 | 79 | return bool(value) | 83 | return bool(value) |
382 | 80 | 84 | ||
383 | 85 | |||
384 | 81 | @lru_cache | 86 | @lru_cache |
385 | 82 | def o2float(value): | 87 | def o2float(value): |
386 | 83 | '''Converts strings like 42%, 123M, 1.2B into floating point numbers | 88 | '''Converts strings like 42%, 123M, 1.2B into floating point numbers |
387 | @@ -93,21 +98,21 @@ def o2float(value): | |||
388 | 93 | elif value == '--': | 98 | elif value == '--': |
389 | 94 | return 0.0 | 99 | return 0.0 |
390 | 95 | 100 | ||
393 | 96 | value = value.replace(',','') | 101 | value = value.replace(',', '') |
394 | 97 | last = value[len(value)-1] | 102 | last = value[len(value) - 1] |
395 | 98 | if last == 'M': | 103 | if last == 'M': |
396 | 99 | return float(value[:-1]) | 104 | return float(value[:-1]) |
397 | 100 | elif last == 'B': | 105 | elif last == 'B': |
398 | 101 | return float(value[:-1]) * 1000 | 106 | return float(value[:-1]) * 1000 |
399 | 102 | elif last == '%': | 107 | elif last == '%': |
401 | 103 | return float(value[:-1])/100.0 | 108 | return float(value[:-1]) / 100.0 |
402 | 104 | elif last == ')' and value[0] == '(': | 109 | elif last == ')' and value[0] == '(': |
403 | 105 | return -1 * o2float(value[1:-1]) | 110 | return -1 * o2float(value[1:-1]) |
404 | 106 | 111 | ||
405 | 107 | try: | 112 | try: |
406 | 108 | return float(value) | 113 | return float(value) |
407 | 109 | except ValueError: | 114 | except ValueError: |
409 | 110 | sys.stderr.write("ofloat: Could not convert '%s' to float\n" %(value)) | 115 | sys.stderr.write(f"ofloat: Could not convert '{value}' to float\n") |
410 | 111 | raise | 116 | raise |
411 | 112 | 117 | ||
412 | 113 | 118 | ||
413 | @@ -132,10 +137,10 @@ if __name__ == "__main__": | |||
414 | 132 | ({}, False), | 137 | ({}, False), |
415 | 133 | ((), False), | 138 | ((), False), |
416 | 134 | ([1], True), | 139 | ([1], True), |
418 | 135 | ({1:2}, True), | 140 | ({1: 2}, True), |
419 | 136 | ((1,), True), | 141 | ((1,), True), |
420 | 137 | (None, False), | 142 | (None, False), |
421 | 138 | (object(), True), | 143 | (object(), True), |
423 | 139 | ] | 144 | ] |
424 | 140 | for test, expected in test_cases: | 145 | for test, expected in test_cases: |
426 | 141 | assert to_bool(test) == expected, "to_bool("+test+") failed to return "+expected | 146 | assert to_bool(test) == expected, f"to_bool({test}) failed to return {expected}" |
427 | diff --git a/tests/test_lp.py b/tests/test_lp.py | |||
428 | index a8fcdcb..d5978ce 100644 | |||
429 | --- a/tests/test_lp.py | |||
430 | +++ b/tests/test_lp.py | |||
431 | @@ -30,7 +30,7 @@ Tests for our launchpadlib wrapper & helper methods. | |||
432 | 30 | import sys | 30 | import sys |
433 | 31 | import os.path | 31 | import os.path |
434 | 32 | 32 | ||
436 | 33 | from mock import Mock, patch | 33 | from mock import Mock |
437 | 34 | import pytest | 34 | import pytest |
438 | 35 | import logging | 35 | import logging |
439 | 36 | 36 | ||
440 | @@ -41,6 +41,7 @@ from launchpadlib.launchpad import Launchpad | |||
441 | 41 | 41 | ||
442 | 42 | APPNAME = 'test-lp' | 42 | APPNAME = 'test-lp' |
443 | 43 | 43 | ||
444 | 44 | |||
445 | 44 | @pytest.fixture | 45 | @pytest.fixture |
446 | 45 | def fakelp(tmp_path): | 46 | def fakelp(tmp_path): |
447 | 46 | """Connect to Launchpad.""" | 47 | """Connect to Launchpad.""" |
448 | @@ -71,16 +72,19 @@ def test_new_connection(tmp_path): | |||
449 | 71 | version='devel', | 72 | version='devel', |
450 | 72 | ) | 73 | ) |
451 | 73 | 74 | ||
452 | 75 | |||
453 | 74 | def test_api_root(fakelp): | 76 | def test_api_root(fakelp): |
454 | 75 | """Ensure we can get LP's API root.""" | 77 | """Ensure we can get LP's API root.""" |
455 | 76 | fakelp.load(Lp.API_ROOT_URL + 'hi') | 78 | fakelp.load(Lp.API_ROOT_URL + 'hi') |
456 | 77 | fakelp._instance.load.assert_called_once_with( | 79 | fakelp._instance.load.assert_called_once_with( |
457 | 78 | 'https://api.launchpad.net/devel/hi') | 80 | 'https://api.launchpad.net/devel/hi') |
458 | 79 | 81 | ||
459 | 82 | |||
460 | 80 | def test_ubuntu(fakelp): | 83 | def test_ubuntu(fakelp): |
462 | 81 | fakelp._instance.distributions={'ubuntu': 'UBUNTU'} | 84 | fakelp._instance.distributions = {'ubuntu': 'UBUNTU'} |
463 | 82 | assert fakelp.ubuntu == 'UBUNTU' | 85 | assert fakelp.ubuntu == 'UBUNTU' |
464 | 83 | 86 | ||
465 | 87 | |||
466 | 84 | def test_ubuntu_active_series(fakelp): | 88 | def test_ubuntu_active_series(fakelp): |
467 | 85 | mock_hirsute = Mock(active=False) | 89 | mock_hirsute = Mock(active=False) |
468 | 86 | mock_hirsute.name = 'hirsute' | 90 | mock_hirsute.name = 'hirsute' |
469 | @@ -93,10 +97,12 @@ def test_ubuntu_active_series(fakelp): | |||
470 | 93 | assert fakelp.ubuntu_active_series()[0] == mock_jammy | 97 | assert fakelp.ubuntu_active_series()[0] == mock_jammy |
471 | 94 | assert fakelp.ubuntu_active_series()[0].name == 'jammy' | 98 | assert fakelp.ubuntu_active_series()[0].name == 'jammy' |
472 | 95 | 99 | ||
473 | 100 | |||
474 | 96 | def test_debian(fakelp): | 101 | def test_debian(fakelp): |
476 | 97 | fakelp._instance.distributions={'debian': 'DEBIAN'} | 102 | fakelp._instance.distributions = {'debian': 'DEBIAN'} |
477 | 98 | assert fakelp.debian == 'DEBIAN' | 103 | assert fakelp.debian == 'DEBIAN' |
478 | 99 | 104 | ||
479 | 105 | |||
480 | 100 | def test_debian_active_series(fakelp): | 106 | def test_debian_active_series(fakelp): |
481 | 101 | mock_woody = Mock(active=False) | 107 | mock_woody = Mock(active=False) |
482 | 102 | mock_woody.name = 'woody' | 108 | mock_woody.name = 'woody' |
483 | @@ -111,6 +117,7 @@ def test_debian_active_series(fakelp): | |||
484 | 111 | fakelp._instance.distributions = {'debian': mock_debian} | 117 | fakelp._instance.distributions = {'debian': mock_debian} |
485 | 112 | assert fakelp.debian_active_series()[0].name == 'buster' | 118 | assert fakelp.debian_active_series()[0].name == 'buster' |
486 | 113 | 119 | ||
487 | 120 | |||
488 | 114 | def test_debian_experimental_series(fakelp): | 121 | def test_debian_experimental_series(fakelp): |
489 | 115 | mock_woody = Mock(active=False) | 122 | mock_woody = Mock(active=False) |
490 | 116 | mock_woody.name = 'woody' | 123 | mock_woody.name = 'woody' |
491 | @@ -125,6 +132,7 @@ def test_debian_experimental_series(fakelp): | |||
492 | 125 | fakelp._instance.distributions = {'debian': mock_debian} | 132 | fakelp._instance.distributions = {'debian': mock_debian} |
493 | 126 | assert fakelp.debian_experimental_series() == mock_sid | 133 | assert fakelp.debian_experimental_series() == mock_sid |
494 | 127 | 134 | ||
495 | 135 | |||
496 | 128 | def test_ppa_team(fakelp): | 136 | def test_ppa_team(fakelp): |
497 | 129 | """Return the PPA team object.""" | 137 | """Return the PPA team object.""" |
498 | 130 | mock_me = Mock(memberships_details=[ | 138 | mock_me = Mock(memberships_details=[ |
499 | diff --git a/tests/test_ppa.py b/tests/test_ppa.py | |||
500 | index a632228..a71336f 100644 | |||
501 | --- a/tests/test_ppa.py | |||
502 | +++ b/tests/test_ppa.py | |||
503 | @@ -11,10 +11,8 @@ | |||
504 | 11 | import os | 11 | import os |
505 | 12 | import sys | 12 | import sys |
506 | 13 | 13 | ||
507 | 14 | import pytest | ||
508 | 15 | |||
509 | 16 | sys.path.insert(0, os.path.realpath( | 14 | sys.path.insert(0, os.path.realpath( |
511 | 17 | os.path.join(os.path.dirname(__file__), ".."))) | 15 | os.path.join(os.path.dirname(__file__), ".."))) |
512 | 18 | 16 | ||
513 | 19 | from ppa.ppa import Ppa | 17 | from ppa.ppa import Ppa |
514 | 20 | 18 | ||
515 | @@ -24,12 +22,14 @@ def test_object(): | |||
516 | 24 | ppa = Ppa('test-ppa-name', 'test-team-name') | 22 | ppa = Ppa('test-ppa-name', 'test-team-name') |
517 | 25 | assert ppa | 23 | assert ppa |
518 | 26 | 24 | ||
519 | 25 | |||
520 | 27 | def test_description(): | 26 | def test_description(): |
521 | 28 | """Check specifying a description when creating a PPA""" | 27 | """Check specifying a description when creating a PPA""" |
522 | 29 | ppa = Ppa('test-ppa-name', 'test-team-name', 'test-description') | 28 | ppa = Ppa('test-ppa-name', 'test-team-name', 'test-description') |
523 | 30 | 29 | ||
524 | 31 | assert 'test-description' in ppa.ppa_description | 30 | assert 'test-description' in ppa.ppa_description |
525 | 32 | 31 | ||
526 | 32 | |||
527 | 33 | def test_address(): | 33 | def test_address(): |
528 | 34 | """Check getting the PPA address""" | 34 | """Check getting the PPA address""" |
529 | 35 | ppa = Ppa('test', 'team') | 35 | ppa = Ppa('test', 'team') |
530 | diff --git a/tests/test_ppa_group.py b/tests/test_ppa_group.py | |||
531 | index dd45e80..e03a841 100644 | |||
532 | --- a/tests/test_ppa_group.py | |||
533 | +++ b/tests/test_ppa_group.py | |||
534 | @@ -14,11 +14,12 @@ import sys | |||
535 | 14 | import pytest | 14 | import pytest |
536 | 15 | 15 | ||
537 | 16 | sys.path.insert(0, os.path.realpath( | 16 | sys.path.insert(0, os.path.realpath( |
539 | 17 | os.path.join(os.path.dirname(__file__), ".."))) | 17 | os.path.join(os.path.dirname(__file__), ".."))) |
540 | 18 | 18 | ||
541 | 19 | from ppa.ppa import Ppa | 19 | from ppa.ppa import Ppa |
542 | 20 | from ppa.ppa_group import PpaGroup, PpaAlreadyExists | 20 | from ppa.ppa_group import PpaGroup, PpaAlreadyExists |
543 | 21 | 21 | ||
544 | 22 | |||
545 | 22 | class PersonMock: | 23 | class PersonMock: |
546 | 23 | def __init__(self, name): | 24 | def __init__(self, name): |
547 | 24 | self.name = name | 25 | self.name = name |
548 | @@ -42,10 +43,10 @@ class PersonMock: | |||
549 | 42 | 43 | ||
550 | 43 | class LaunchpadMock: | 44 | class LaunchpadMock: |
551 | 44 | def __init__(self): | 45 | def __init__(self): |
553 | 45 | self.people = { 'me': PersonMock('me') } | 46 | self.people = {'me': PersonMock('me')} |
554 | 46 | 47 | ||
555 | 47 | def add_person(self, name): | 48 | def add_person(self, name): |
557 | 48 | print("Adding person %s" %(name)) | 49 | print(f"Adding person {name}") |
558 | 49 | self.people[name] = PersonMock(name) | 50 | self.people[name] = PersonMock(name) |
559 | 50 | 51 | ||
560 | 51 | @property | 52 | @property |
561 | @@ -83,6 +84,7 @@ def test_object(): | |||
562 | 83 | ppa_group = PpaGroup(service=LpServiceMock()) | 84 | ppa_group = PpaGroup(service=LpServiceMock()) |
563 | 84 | assert(ppa_group) | 85 | assert(ppa_group) |
564 | 85 | 86 | ||
565 | 87 | |||
566 | 86 | def test_create_ppa(): | 88 | def test_create_ppa(): |
567 | 87 | """Checks that PpaGroups can create PPAs""" | 89 | """Checks that PpaGroups can create PPAs""" |
568 | 88 | name = 'test_ppa' | 90 | name = 'test_ppa' |
569 | @@ -92,13 +94,15 @@ def test_create_ppa(): | |||
570 | 92 | assert(name in ppa.address) | 94 | assert(name in ppa.address) |
571 | 93 | assert(type(ppa.description) is str) | 95 | assert(type(ppa.description) is str) |
572 | 94 | 96 | ||
573 | 97 | |||
574 | 95 | def test_create_existing_ppa(): | 98 | def test_create_existing_ppa(): |
575 | 96 | """Check exception creating an already created PPA""" | 99 | """Check exception creating an already created PPA""" |
576 | 97 | name = 'test_ppa' | 100 | name = 'test_ppa' |
577 | 98 | ppa_group = PpaGroup(service=LpServiceMock()) | 101 | ppa_group = PpaGroup(service=LpServiceMock()) |
579 | 99 | ppa = ppa_group.create(name) | 102 | ppa_group.create(name) |
580 | 100 | with pytest.raises(PpaAlreadyExists): | 103 | with pytest.raises(PpaAlreadyExists): |
582 | 101 | ppa = ppa_group.create(name) | 104 | ppa_group.create(name) |
583 | 105 | |||
584 | 102 | 106 | ||
585 | 103 | def test_create_with_description(): | 107 | def test_create_with_description(): |
586 | 104 | """Check setting a description for a PPA""" | 108 | """Check setting a description for a PPA""" |
587 | @@ -108,6 +112,7 @@ def test_create_with_description(): | |||
588 | 108 | assert(ppa is not None) | 112 | assert(ppa is not None) |
589 | 109 | assert(ppa.description == description) | 113 | assert(ppa.description == description) |
590 | 110 | 114 | ||
591 | 115 | |||
592 | 111 | def test_create_with_team(): | 116 | def test_create_with_team(): |
593 | 112 | """Check creating a PPA for a particular team""" | 117 | """Check creating a PPA for a particular team""" |
594 | 113 | lp = LpServiceMock() | 118 | lp = LpServiceMock() |
595 | @@ -117,22 +122,25 @@ def test_create_with_team(): | |||
596 | 117 | assert(ppa is not None) | 122 | assert(ppa is not None) |
597 | 118 | assert(ppa.address == 'ppa:test_team_name/ppa_test_name') | 123 | assert(ppa.address == 'ppa:test_team_name/ppa_test_name') |
598 | 119 | 124 | ||
599 | 125 | |||
600 | 120 | def test_create_for_lpbug(): | 126 | def test_create_for_lpbug(): |
601 | 121 | """Check associating a bug # when creating a PPA""" | 127 | """Check associating a bug # when creating a PPA""" |
602 | 122 | ppa_group = PpaGroup(service=LpServiceMock()) | 128 | ppa_group = PpaGroup(service=LpServiceMock()) |
603 | 123 | lpbug = '1234567' | 129 | lpbug = '1234567' |
605 | 124 | ppa = ppa_group.create('lp'+lpbug) | 130 | ppa = ppa_group.create('lp' + lpbug) |
606 | 125 | assert(ppa is not None) | 131 | assert(ppa is not None) |
607 | 126 | assert(lpbug in ppa.description) | 132 | assert(lpbug in ppa.description) |
608 | 127 | 133 | ||
609 | 134 | |||
610 | 128 | def test_create_for_merge_proposal(): | 135 | def test_create_for_merge_proposal(): |
611 | 129 | """Check associating a merge proposal when creating a PPA""" | 136 | """Check associating a merge proposal when creating a PPA""" |
612 | 130 | ppa_group = PpaGroup(service=LpServiceMock()) | 137 | ppa_group = PpaGroup(service=LpServiceMock()) |
613 | 131 | version = '1.2.3-4' | 138 | version = '1.2.3-4' |
615 | 132 | ppa = ppa_group.create('merge.'+version) | 139 | ppa = ppa_group.create('merge.' + version) |
616 | 133 | assert(ppa is not None) | 140 | assert(ppa is not None) |
617 | 134 | assert(version in ppa.description) | 141 | assert(version in ppa.description) |
618 | 135 | 142 | ||
619 | 143 | |||
620 | 136 | def test_list_ppas(): | 144 | def test_list_ppas(): |
621 | 137 | """Check listing the PPAs for a PPA group""" | 145 | """Check listing the PPAs for a PPA group""" |
622 | 138 | test_ppa_list = ['a', 'b', 'c', 'd'] | 146 | test_ppa_list = ['a', 'b', 'c', 'd'] |
623 | diff --git a/tests/test_scripts_ppa.py b/tests/test_scripts_ppa.py | |||
624 | index dc4e411..4c37e29 100644 | |||
625 | --- a/tests/test_scripts_ppa.py | |||
626 | +++ b/tests/test_scripts_ppa.py | |||
627 | @@ -25,14 +25,15 @@ loader = importlib.machinery.SourceFileLoader(SCRIPT_NAME, script_path) | |||
628 | 25 | script = types.ModuleType(loader.name) | 25 | script = types.ModuleType(loader.name) |
629 | 26 | loader.exec_module(script) | 26 | loader.exec_module(script) |
630 | 27 | 27 | ||
631 | 28 | |||
632 | 28 | @pytest.fixture | 29 | @pytest.fixture |
633 | 29 | def fake_config(): | 30 | def fake_config(): |
634 | 30 | return { | 31 | return { |
635 | 31 | 'ppa_name': 'testing', | 32 | 'ppa_name': 'testing', |
636 | 32 | 'team_name': 'tester', | 33 | 'team_name': 'tester', |
637 | 33 | 'wait_seconds': 0.1 | 34 | 'wait_seconds': 0.1 |
640 | 34 | } | 35 | } |
641 | 35 | return script.create_config(args) | 36 | |
642 | 36 | 37 | ||
643 | 37 | @pytest.fixture | 38 | @pytest.fixture |
644 | 38 | def fake_source_package(): | 39 | def fake_source_package(): |
645 | @@ -41,10 +42,11 @@ def fake_source_package(): | |||
646 | 41 | 'name': 'test-source', | 42 | 'name': 'test-source', |
647 | 42 | 'version': '1.0-2ubuntu3', | 43 | 'version': '1.0-2ubuntu3', |
648 | 43 | 'binaries': [ | 44 | 'binaries': [ |
653 | 44 | { 'name': 'foo', } | 45 | {'name': 'foo'}, |
654 | 45 | { 'name': 'bar', } | 46 | {'name': 'bar'} |
655 | 46 | ] | 47 | ] |
656 | 47 | } | 48 | } |
657 | 49 | |||
658 | 48 | 50 | ||
659 | 49 | @pytest.fixture | 51 | @pytest.fixture |
660 | 50 | def fake_binary_package(): | 52 | def fake_binary_package(): |
661 | @@ -52,7 +54,8 @@ def fake_binary_package(): | |||
662 | 52 | return { | 54 | return { |
663 | 53 | 'name': 'test-binary', | 55 | 'name': 'test-binary', |
664 | 54 | 'source': 'test-source', | 56 | 'source': 'test-source', |
666 | 55 | } | 57 | } |
667 | 58 | |||
668 | 56 | 59 | ||
669 | 57 | @pytest.fixture | 60 | @pytest.fixture |
670 | 58 | def fake_build(): | 61 | def fake_build(): |
671 | @@ -60,7 +63,8 @@ def fake_build(): | |||
672 | 60 | return { | 63 | return { |
673 | 61 | 'binary': 'foo', | 64 | 'binary': 'foo', |
674 | 62 | 'status': 'Failed', | 65 | 'status': 'Failed', |
676 | 63 | } | 66 | } |
677 | 67 | |||
678 | 64 | 68 | ||
679 | 65 | @pytest.fixture | 69 | @pytest.fixture |
680 | 66 | def fake_bug_report(): | 70 | def fake_bug_report(): |
681 | @@ -69,10 +73,11 @@ def fake_bug_report(): | |||
682 | 69 | 'id': 1234, | 73 | 'id': 1234, |
683 | 70 | 'title': 'foobar', | 74 | 'title': 'foobar', |
684 | 71 | 'desc': 'baz', | 75 | 'desc': 'baz', |
686 | 72 | } | 76 | } |
687 | 77 | |||
688 | 73 | 78 | ||
689 | 74 | def test_create_parser(): | 79 | def test_create_parser(): |
691 | 75 | parser = script.create_parser() | 80 | # parser = script.create_parser() |
692 | 76 | 81 | ||
693 | 77 | # TODO: Don't I have an existing example arg-parse test somewhere? | 82 | # TODO: Don't I have an existing example arg-parse test somewhere? |
694 | 78 | # TODO: Check command is recognized | 83 | # TODO: Check command is recognized |
695 | @@ -85,74 +90,87 @@ def test_create_parser(): | |||
696 | 85 | 90 | ||
697 | 86 | pass | 91 | pass |
698 | 87 | 92 | ||
699 | 93 | |||
700 | 88 | @pytest.mark.xfail(reason="Unimplemented") | 94 | @pytest.mark.xfail(reason="Unimplemented") |
701 | 89 | def test_create_config(): | 95 | def test_create_config(): |
703 | 90 | args = [] | 96 | # args = [] |
704 | 91 | # TODO: Set config_filename, ppa_name, team_name in args | 97 | # TODO: Set config_filename, ppa_name, team_name in args |
706 | 92 | config = script.create_config(args) | 98 | # config = script.create_config(args) |
707 | 93 | 99 | ||
708 | 94 | pass | 100 | pass |
709 | 95 | 101 | ||
710 | 102 | |||
711 | 96 | # TODO: Monkeypatch in Lp = MockLp | 103 | # TODO: Monkeypatch in Lp = MockLp |
712 | 97 | @pytest.mark.xfail(reason="Unimplemented") | 104 | @pytest.mark.xfail(reason="Unimplemented") |
713 | 98 | def test_get_ppa(): | 105 | def test_get_ppa(): |
714 | 99 | # TODO: In fake_config, set ppa_name, team_name, and lp | 106 | # TODO: In fake_config, set ppa_name, team_name, and lp |
716 | 100 | ppa = script.get_ppa(fake_config) | 107 | # ppa = script.get_ppa(fake_config) |
717 | 101 | # TODO: Verify type(ppa) is Ppa | 108 | # TODO: Verify type(ppa) is Ppa |
718 | 102 | # TODO: Verify that ppa_name is set properly in ppa | 109 | # TODO: Verify that ppa_name is set properly in ppa |
719 | 103 | # TODO: Verify that team_name is set properly in ppa | 110 | # TODO: Verify that team_name is set properly in ppa |
720 | 104 | # TODO: Verify that lp is set properly in ppa | 111 | # TODO: Verify that lp is set properly in ppa |
721 | 112 | pass | ||
722 | 113 | |||
723 | 105 | 114 | ||
724 | 106 | @pytest.mark.xfail(reason="Unimplemented") | 115 | @pytest.mark.xfail(reason="Unimplemented") |
725 | 107 | def test_command_create(fake_config): | 116 | def test_command_create(fake_config): |
727 | 108 | assert command_create(fake_config) == 0 | 117 | assert script.command_create(fake_config) == 0 |
728 | 109 | 118 | ||
729 | 110 | # TODO: Specify a ppa_name and verify it gets used properly | 119 | # TODO: Specify a ppa_name and verify it gets used properly |
730 | 111 | # TODO: Specify a team name | 120 | # TODO: Specify a team name |
731 | 112 | # TODO: Verify if no team name specified, the lp_user is used | 121 | # TODO: Verify if no team name specified, the lp_user is used |
732 | 113 | # instead | 122 | # instead |
733 | 114 | # TODO: Verify the ppa_address is set as expected | 123 | # TODO: Verify the ppa_address is set as expected |
734 | 124 | pass | ||
735 | 125 | |||
736 | 115 | 126 | ||
737 | 116 | @pytest.mark.xfail(reason="Unimplemented") | 127 | @pytest.mark.xfail(reason="Unimplemented") |
738 | 117 | def test_command_desc(fake_config): | 128 | def test_command_desc(fake_config): |
740 | 118 | assert command_desc(fake_config) == 0 | 129 | assert script.command_desc(fake_config) == 0 |
741 | 119 | # TODO: Assert that if --dry-run specified, there are no actual | 130 | # TODO: Assert that if --dry-run specified, there are no actual |
742 | 120 | # changes requested of launchpad | 131 | # changes requested of launchpad |
743 | 121 | # TODO: Verify the description gets set as expected | 132 | # TODO: Verify the description gets set as expected |
744 | 122 | 133 | ||
745 | 134 | |||
746 | 123 | @pytest.mark.xfail(reason="Unimplemented") | 135 | @pytest.mark.xfail(reason="Unimplemented") |
747 | 124 | def test_command_destroy(fake_config): | 136 | def test_command_destroy(fake_config): |
748 | 125 | # TODO: Create a fake ppa to be destroyed | 137 | # TODO: Create a fake ppa to be destroyed |
750 | 126 | assert command_destroy(fake_config) == 0 | 138 | assert script.command_destroy(fake_config) == 0 |
751 | 127 | # TODO: Verify the ppa is requested to be deleted | 139 | # TODO: Verify the ppa is requested to be deleted |
752 | 128 | 140 | ||
753 | 141 | |||
754 | 129 | @pytest.mark.xfail(reason="Unimplemented") | 142 | @pytest.mark.xfail(reason="Unimplemented") |
755 | 130 | def test_command_list(fake_config): | 143 | def test_command_list(fake_config): |
756 | 131 | # TODO: Create a fake ppa with contents to be listed | 144 | # TODO: Create a fake ppa with contents to be listed |
758 | 132 | assert command_list(fake_config) == 0 | 145 | assert script.command_list(fake_config) == 0 |
759 | 133 | # TODO: Verify the ppa addresses get listed | 146 | # TODO: Verify the ppa addresses get listed |
760 | 134 | 147 | ||
761 | 148 | |||
762 | 135 | @pytest.mark.xfail(reason="Unimplemented") | 149 | @pytest.mark.xfail(reason="Unimplemented") |
763 | 136 | def test_command_exists(fake_config): | 150 | def test_command_exists(fake_config): |
764 | 137 | # TODO: Create fake ppa that exists | 151 | # TODO: Create fake ppa that exists |
766 | 138 | assert command_exists(fake_config) == 0 | 152 | assert script.command_exists(fake_config) == 0 |
767 | 139 | # TODO: Verify this returns true when the ppa does exist | 153 | # TODO: Verify this returns true when the ppa does exist |
768 | 140 | 154 | ||
769 | 155 | |||
770 | 141 | @pytest.mark.xfail(reason="Unimplemented") | 156 | @pytest.mark.xfail(reason="Unimplemented") |
771 | 142 | def test_command_not_exists(fake_config): | 157 | def test_command_not_exists(fake_config): |
772 | 143 | # TODO: Verify this returns true when the ppa does not exist | 158 | # TODO: Verify this returns true when the ppa does not exist |
774 | 144 | assert command_exists(fake_config) == 1 | 159 | assert script.command_exists(fake_config) == 1 |
775 | 160 | |||
776 | 145 | 161 | ||
777 | 146 | @pytest.mark.xfail(reason="Unimplemented") | 162 | @pytest.mark.xfail(reason="Unimplemented") |
778 | 147 | def test_command_show(fake_config): | 163 | def test_command_show(fake_config): |
780 | 148 | assert command_show(fake_config) == 0 | 164 | assert script.command_show(fake_config) == 0 |
781 | 165 | |||
782 | 149 | 166 | ||
783 | 150 | @pytest.mark.xfail(reason="Unimplemented") | 167 | @pytest.mark.xfail(reason="Unimplemented") |
784 | 151 | def test_command_status(fake_config): | 168 | def test_command_status(fake_config): |
786 | 152 | assert command_status(fake_config) == 0 | 169 | assert script.command_status(fake_config) == 0 |
787 | 153 | # TODO: Capture stdout and compare with expected | 170 | # TODO: Capture stdout and compare with expected |
788 | 154 | 171 | ||
789 | 172 | |||
790 | 155 | @pytest.mark.xfail(reason="Unimplemented") | 173 | @pytest.mark.xfail(reason="Unimplemented") |
791 | 156 | def test_command_wait(fake_config): | 174 | def test_command_wait(fake_config): |
792 | 157 | # TODO: Set wait period to 1 sec | 175 | # TODO: Set wait period to 1 sec |
794 | 158 | assert command_wait(fake_config) == 0 | 176 | assert script.command_wait(fake_config) == 0 |
795 | diff --git a/tests/test_version.py b/tests/test_version.py | |||
796 | index 0a1c397..fa6066f 100644 | |||
797 | --- a/tests/test_version.py | |||
798 | +++ b/tests/test_version.py | |||
799 | @@ -11,9 +11,7 @@ | |||
800 | 11 | import os | 11 | import os |
801 | 12 | import sys | 12 | import sys |
802 | 13 | sys.path.insert(0, os.path.realpath( | 13 | sys.path.insert(0, os.path.realpath( |
806 | 14 | os.path.join(os.path.dirname(__file__), ".."))) | 14 | os.path.join(os.path.dirname(__file__), ".."))) |
804 | 15 | |||
805 | 16 | import pytest | ||
807 | 17 | 15 | ||
808 | 18 | from ppa._version import __version__, __version_info__ | 16 | from ppa._version import __version__, __version_info__ |
809 | 19 | 17 | ||
810 | @@ -24,6 +22,7 @@ def test_version(): | |||
811 | 24 | assert(__version__[0].isdigit()) | 22 | assert(__version__[0].isdigit()) |
812 | 25 | assert(__version__[-1] != '.') | 23 | assert(__version__[-1] != '.') |
813 | 26 | 24 | ||
814 | 25 | |||
815 | 27 | def test_version_info(): | 26 | def test_version_info(): |
816 | 28 | assert(type(__version_info__) is tuple) | 27 | assert(type(__version_info__) is tuple) |
817 | 29 | assert(len(__version_info__) > 1) | 28 | assert(len(__version_info__) > 1) |
Really seems to be just cleanups, whitespace lines, line length, f-string, import order and useless imports ... the stuff you know from your friendly linters.
I didn't see anything odd, therefore +1 to this