Merge lp:~ericsnowcurrently/fake-juju/python-lib-helpers into lp:~landscape/fake-juju/trunk-old
- python-lib-helpers
- Merge into trunk-old
Proposed by
Eric Snow
Status: | Superseded |
---|---|
Proposed branch: | lp:~ericsnowcurrently/fake-juju/python-lib-helpers |
Merge into: | lp:~landscape/fake-juju/trunk-old |
Diff against target: |
531 lines (+493/-0) 7 files modified
python/LICENSE (+191/-0) python/Makefile (+9/-0) python/README.md (+1/-0) python/fakejuju/__init__.py (+48/-0) python/fakejuju/fakejuju.py (+45/-0) python/fakejuju/tests/test_fakejuju.py (+130/-0) python/setup.py (+69/-0) |
To merge this branch: | bzr merge lp:~ericsnowcurrently/fake-juju/python-lib-helpers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
🤖 Landscape Builder | test results | Approve | |
Landscape | Pending | ||
Landscape | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2016-10-06.
Commit message
Description of the change
Add helper functions to the fakejuju.fakejuju module.
Testing instructions:
Run the unit tests.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) : | # |
review:
Abstain
(executing tests)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) wrote : | # |
review:
Approve
(test results)
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'python' | |||
2 | === added file 'python/LICENSE' | |||
3 | --- python/LICENSE 1970-01-01 00:00:00 +0000 | |||
4 | +++ python/LICENSE 2016-10-06 22:15:11 +0000 | |||
5 | @@ -0,0 +1,191 @@ | |||
6 | 1 | All files in this repository are licensed as follows. If you contribute | ||
7 | 2 | to this repository, it is assumed that you license your contribution | ||
8 | 3 | under the same license unless you state otherwise. | ||
9 | 4 | |||
10 | 5 | All files Copyright (C) 2012-2016 Canonical Ltd. unless otherwise specified in the file. | ||
11 | 6 | |||
12 | 7 | This software is licensed under the LGPLv3, included below. | ||
13 | 8 | |||
14 | 9 | As a special exception to the GNU Lesser General Public License version 3 | ||
15 | 10 | ("LGPL3"), the copyright holders of this Library give you permission to | ||
16 | 11 | convey to a third party a Combined Work that links statically or dynamically | ||
17 | 12 | to this Library without providing any Minimal Corresponding Source or | ||
18 | 13 | Minimal Application Code as set out in 4d or providing the installation | ||
19 | 14 | information set out in section 4e, provided that you comply with the other | ||
20 | 15 | provisions of LGPL3 and provided that you meet, for the Application the | ||
21 | 16 | terms and conditions of the license(s) which apply to the Application. | ||
22 | 17 | |||
23 | 18 | Except as stated in this special exception, the provisions of LGPL3 will | ||
24 | 19 | continue to comply in full to this Library. If you modify this Library, you | ||
25 | 20 | may apply this exception to your version of this Library, but you are not | ||
26 | 21 | obliged to do so. If you do not wish to do so, delete this exception | ||
27 | 22 | statement from your version. This exception does not (and cannot) modify any | ||
28 | 23 | license terms which apply to the Application, with which you must still | ||
29 | 24 | comply. | ||
30 | 25 | |||
31 | 26 | |||
32 | 27 | GNU LESSER GENERAL PUBLIC LICENSE | ||
33 | 28 | Version 3, 29 June 2007 | ||
34 | 29 | |||
35 | 30 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||
36 | 31 | Everyone is permitted to copy and distribute verbatim copies | ||
37 | 32 | of this license document, but changing it is not allowed. | ||
38 | 33 | |||
39 | 34 | |||
40 | 35 | This version of the GNU Lesser General Public License incorporates | ||
41 | 36 | the terms and conditions of version 3 of the GNU General Public | ||
42 | 37 | License, supplemented by the additional permissions listed below. | ||
43 | 38 | |||
44 | 39 | 0. Additional Definitions. | ||
45 | 40 | |||
46 | 41 | As used herein, "this License" refers to version 3 of the GNU Lesser | ||
47 | 42 | General Public License, and the "GNU GPL" refers to version 3 of the GNU | ||
48 | 43 | General Public License. | ||
49 | 44 | |||
50 | 45 | "The Library" refers to a covered work governed by this License, | ||
51 | 46 | other than an Application or a Combined Work as defined below. | ||
52 | 47 | |||
53 | 48 | An "Application" is any work that makes use of an interface provided | ||
54 | 49 | by the Library, but which is not otherwise based on the Library. | ||
55 | 50 | Defining a subclass of a class defined by the Library is deemed a mode | ||
56 | 51 | of using an interface provided by the Library. | ||
57 | 52 | |||
58 | 53 | A "Combined Work" is a work produced by combining or linking an | ||
59 | 54 | Application with the Library. The particular version of the Library | ||
60 | 55 | with which the Combined Work was made is also called the "Linked | ||
61 | 56 | Version". | ||
62 | 57 | |||
63 | 58 | The "Minimal Corresponding Source" for a Combined Work means the | ||
64 | 59 | Corresponding Source for the Combined Work, excluding any source code | ||
65 | 60 | for portions of the Combined Work that, considered in isolation, are | ||
66 | 61 | based on the Application, and not on the Linked Version. | ||
67 | 62 | |||
68 | 63 | The "Corresponding Application Code" for a Combined Work means the | ||
69 | 64 | object code and/or source code for the Application, including any data | ||
70 | 65 | and utility programs needed for reproducing the Combined Work from the | ||
71 | 66 | Application, but excluding the System Libraries of the Combined Work. | ||
72 | 67 | |||
73 | 68 | 1. Exception to Section 3 of the GNU GPL. | ||
74 | 69 | |||
75 | 70 | You may convey a covered work under sections 3 and 4 of this License | ||
76 | 71 | without being bound by section 3 of the GNU GPL. | ||
77 | 72 | |||
78 | 73 | 2. Conveying Modified Versions. | ||
79 | 74 | |||
80 | 75 | If you modify a copy of the Library, and, in your modifications, a | ||
81 | 76 | facility refers to a function or data to be supplied by an Application | ||
82 | 77 | that uses the facility (other than as an argument passed when the | ||
83 | 78 | facility is invoked), then you may convey a copy of the modified | ||
84 | 79 | version: | ||
85 | 80 | |||
86 | 81 | a) under this License, provided that you make a good faith effort to | ||
87 | 82 | ensure that, in the event an Application does not supply the | ||
88 | 83 | function or data, the facility still operates, and performs | ||
89 | 84 | whatever part of its purpose remains meaningful, or | ||
90 | 85 | |||
91 | 86 | b) under the GNU GPL, with none of the additional permissions of | ||
92 | 87 | this License applicable to that copy. | ||
93 | 88 | |||
94 | 89 | 3. Object Code Incorporating Material from Library Header Files. | ||
95 | 90 | |||
96 | 91 | The object code form of an Application may incorporate material from | ||
97 | 92 | a header file that is part of the Library. You may convey such object | ||
98 | 93 | code under terms of your choice, provided that, if the incorporated | ||
99 | 94 | material is not limited to numerical parameters, data structure | ||
100 | 95 | layouts and accessors, or small macros, inline functions and templates | ||
101 | 96 | (ten or fewer lines in length), you do both of the following: | ||
102 | 97 | |||
103 | 98 | a) Give prominent notice with each copy of the object code that the | ||
104 | 99 | Library is used in it and that the Library and its use are | ||
105 | 100 | covered by this License. | ||
106 | 101 | |||
107 | 102 | b) Accompany the object code with a copy of the GNU GPL and this license | ||
108 | 103 | document. | ||
109 | 104 | |||
110 | 105 | 4. Combined Works. | ||
111 | 106 | |||
112 | 107 | You may convey a Combined Work under terms of your choice that, | ||
113 | 108 | taken together, effectively do not restrict modification of the | ||
114 | 109 | portions of the Library contained in the Combined Work and reverse | ||
115 | 110 | engineering for debugging such modifications, if you also do each of | ||
116 | 111 | the following: | ||
117 | 112 | |||
118 | 113 | a) Give prominent notice with each copy of the Combined Work that | ||
119 | 114 | the Library is used in it and that the Library and its use are | ||
120 | 115 | covered by this License. | ||
121 | 116 | |||
122 | 117 | b) Accompany the Combined Work with a copy of the GNU GPL and this license | ||
123 | 118 | document. | ||
124 | 119 | |||
125 | 120 | c) For a Combined Work that displays copyright notices during | ||
126 | 121 | execution, include the copyright notice for the Library among | ||
127 | 122 | these notices, as well as a reference directing the user to the | ||
128 | 123 | copies of the GNU GPL and this license document. | ||
129 | 124 | |||
130 | 125 | d) Do one of the following: | ||
131 | 126 | |||
132 | 127 | 0) Convey the Minimal Corresponding Source under the terms of this | ||
133 | 128 | License, and the Corresponding Application Code in a form | ||
134 | 129 | suitable for, and under terms that permit, the user to | ||
135 | 130 | recombine or relink the Application with a modified version of | ||
136 | 131 | the Linked Version to produce a modified Combined Work, in the | ||
137 | 132 | manner specified by section 6 of the GNU GPL for conveying | ||
138 | 133 | Corresponding Source. | ||
139 | 134 | |||
140 | 135 | 1) Use a suitable shared library mechanism for linking with the | ||
141 | 136 | Library. A suitable mechanism is one that (a) uses at run time | ||
142 | 137 | a copy of the Library already present on the user's computer | ||
143 | 138 | system, and (b) will operate properly with a modified version | ||
144 | 139 | of the Library that is interface-compatible with the Linked | ||
145 | 140 | Version. | ||
146 | 141 | |||
147 | 142 | e) Provide Installation Information, but only if you would otherwise | ||
148 | 143 | be required to provide such information under section 6 of the | ||
149 | 144 | GNU GPL, and only to the extent that such information is | ||
150 | 145 | necessary to install and execute a modified version of the | ||
151 | 146 | Combined Work produced by recombining or relinking the | ||
152 | 147 | Application with a modified version of the Linked Version. (If | ||
153 | 148 | you use option 4d0, the Installation Information must accompany | ||
154 | 149 | the Minimal Corresponding Source and Corresponding Application | ||
155 | 150 | Code. If you use option 4d1, you must provide the Installation | ||
156 | 151 | Information in the manner specified by section 6 of the GNU GPL | ||
157 | 152 | for conveying Corresponding Source.) | ||
158 | 153 | |||
159 | 154 | 5. Combined Libraries. | ||
160 | 155 | |||
161 | 156 | You may place library facilities that are a work based on the | ||
162 | 157 | Library side by side in a single library together with other library | ||
163 | 158 | facilities that are not Applications and are not covered by this | ||
164 | 159 | License, and convey such a combined library under terms of your | ||
165 | 160 | choice, if you do both of the following: | ||
166 | 161 | |||
167 | 162 | a) Accompany the combined library with a copy of the same work based | ||
168 | 163 | on the Library, uncombined with any other library facilities, | ||
169 | 164 | conveyed under the terms of this License. | ||
170 | 165 | |||
171 | 166 | b) Give prominent notice with the combined library that part of it | ||
172 | 167 | is a work based on the Library, and explaining where to find the | ||
173 | 168 | accompanying uncombined form of the same work. | ||
174 | 169 | |||
175 | 170 | 6. Revised Versions of the GNU Lesser General Public License. | ||
176 | 171 | |||
177 | 172 | The Free Software Foundation may publish revised and/or new versions | ||
178 | 173 | of the GNU Lesser General Public License from time to time. Such new | ||
179 | 174 | versions will be similar in spirit to the present version, but may | ||
180 | 175 | differ in detail to address new problems or concerns. | ||
181 | 176 | |||
182 | 177 | Each version is given a distinguishing version number. If the | ||
183 | 178 | Library as you received it specifies that a certain numbered version | ||
184 | 179 | of the GNU Lesser General Public License "or any later version" | ||
185 | 180 | applies to it, you have the option of following the terms and | ||
186 | 181 | conditions either of that published version or of any later version | ||
187 | 182 | published by the Free Software Foundation. If the Library as you | ||
188 | 183 | received it does not specify a version number of the GNU Lesser | ||
189 | 184 | General Public License, you may choose any version of the GNU Lesser | ||
190 | 185 | General Public License ever published by the Free Software Foundation. | ||
191 | 186 | |||
192 | 187 | If the Library as you received it specifies that a proxy can decide | ||
193 | 188 | whether future versions of the GNU Lesser General Public License shall | ||
194 | 189 | apply, that proxy's public statement of acceptance of any version is | ||
195 | 190 | permanent authorization for you to choose that version for the | ||
196 | 191 | Library. | ||
197 | 0 | 192 | ||
198 | === added file 'python/Makefile' | |||
199 | --- python/Makefile 1970-01-01 00:00:00 +0000 | |||
200 | +++ python/Makefile 2016-10-06 22:15:11 +0000 | |||
201 | @@ -0,0 +1,9 @@ | |||
202 | 1 | PYTHON = python | ||
203 | 2 | |||
204 | 3 | .PHONY: test | ||
205 | 4 | test: | ||
206 | 5 | $(PYTHON) -m unittest discover -t $(shell pwd) -s $(shell pwd)/fakejuju | ||
207 | 6 | |||
208 | 7 | .PHONY: install-dev | ||
209 | 8 | install-dev: | ||
210 | 9 | ln -s $(shell pwd)/fakejuju /usr/local/lib/python2.7/dist-packages/fakejuju | ||
211 | 0 | 10 | ||
212 | === added file 'python/README.md' | |||
213 | --- python/README.md 1970-01-01 00:00:00 +0000 | |||
214 | +++ python/README.md 2016-10-06 22:15:11 +0000 | |||
215 | @@ -0,0 +1,1 @@ | |||
216 | 1 | # fakejuju | ||
217 | 0 | 2 | ||
218 | === added directory 'python/fakejuju' | |||
219 | === added file 'python/fakejuju/__init__.py' | |||
220 | --- python/fakejuju/__init__.py 1970-01-01 00:00:00 +0000 | |||
221 | +++ python/fakejuju/__init__.py 2016-10-06 22:15:11 +0000 | |||
222 | @@ -0,0 +1,48 @@ | |||
223 | 1 | # Copyright 2016 Canonical Limited. All rights reserved. | ||
224 | 2 | |||
225 | 3 | """Support for interaction with fake-juju. | ||
226 | 4 | |||
227 | 5 | "fake-juju" is a combination of the juju and jujud commands that is | ||
228 | 6 | suitable for use in integration tests. It exposes a limited subset | ||
229 | 7 | of the standard juju subcommands (see FakeJuju in this module for | ||
230 | 8 | specifics). When called without any arguments it runs jujud (using | ||
231 | 9 | the dummy provider) with extra logging and testing hooks available to | ||
232 | 10 | control failures. See https://launchpad.net/fake-juju for the project. | ||
233 | 11 | |||
234 | 12 | The binary is named with the Juju version for which it was built. | ||
235 | 13 | For example, for version 1.25.6 the file is named "fake-juju-1.25.6". | ||
236 | 14 | |||
237 | 15 | fake-juju uses the normal Juju local config directory. This defaults | ||
238 | 16 | to ~/.local/shared/juju and may be set using the JUJU_DATA environment | ||
239 | 17 | variable (in 2.x, for 1.x it is JUJU_HOME). | ||
240 | 18 | |||
241 | 19 | In addition to all the normal Juju environment variables (e.g. | ||
242 | 20 | JUJU_DATA), fake-juju uses the following: | ||
243 | 21 | |||
244 | 22 | FAKE_JUJU_FAILURES - the path to the failures file | ||
245 | 23 | The Failures class below sets this to $JUJU_DATA/juju-failures. | ||
246 | 24 | FAKE_JUJU_LOGS_DIR - the path to the logs directory | ||
247 | 25 | This defaults to $JUJU_DATA. | ||
248 | 26 | |||
249 | 27 | fake-juju also creates several extra files: | ||
250 | 28 | |||
251 | 29 | $FAKE_JUJU_LOGS_DIR/fake-juju.log - where fake-juju logs are written | ||
252 | 30 | $JUJU_DATA/fakejuju - fake-juju's data cache | ||
253 | 31 | $JUJU_DATA/fifo - a FIFO file that triggers jujud shutdown | ||
254 | 32 | $JUJU_DATA/cert.ca - the API's CA certificate | ||
255 | 33 | |||
256 | 34 | Normal Juju logging for is written to $JUJU_DATA/fake-juju.log. | ||
257 | 35 | |||
258 | 36 | Failures may be injected into a running fake-juju (or set before | ||
259 | 37 | running). They may be injected by adding them to the file identified | ||
260 | 38 | by $FAKE_JUJU_FAILURES. The format is a single failure definition per | ||
261 | 39 | line. The syntax of the failure definition depends on the failure. | ||
262 | 40 | The currently supported failures (with their definition syntax) are | ||
263 | 41 | listed here: | ||
264 | 42 | |||
265 | 43 | * when adding a unit with a specific ID | ||
266 | 44 | format: "unit-<ID>" (e.g. unit-mysql/0) | ||
267 | 45 | |||
268 | 46 | """ | ||
269 | 47 | |||
270 | 48 | __version__ = "0.9.0b1" | ||
271 | 0 | 49 | ||
272 | === added file 'python/fakejuju/fakejuju.py' | |||
273 | --- python/fakejuju/fakejuju.py 1970-01-01 00:00:00 +0000 | |||
274 | +++ python/fakejuju/fakejuju.py 2016-10-06 22:15:11 +0000 | |||
275 | @@ -0,0 +1,45 @@ | |||
276 | 1 | # Copyright 2016 Canonical Limited. All rights reserved. | ||
277 | 2 | |||
278 | 3 | import os.path | ||
279 | 4 | |||
280 | 5 | import txjuju.cli | ||
281 | 6 | |||
282 | 7 | |||
283 | 8 | def get_bootstrap_spec(name, admin_secret=None): | ||
284 | 9 | """Return the BootstrapSpec instance for the given controller. | ||
285 | 10 | |||
286 | 11 | @param name: The controller name to set up. | ||
287 | 12 | @param admin_secret: The admin user password to use. | ||
288 | 13 | """ | ||
289 | 14 | type = "dummy" | ||
290 | 15 | default_series = None # Use the default. | ||
291 | 16 | return txjuju.cli.BootstrapSpec(name, type, default_series, admin_secret) | ||
292 | 17 | |||
293 | 18 | |||
294 | 19 | def get_filename(version, bindir=None): | ||
295 | 20 | """Return the full path to the fake-juju binary for the given version. | ||
296 | 21 | |||
297 | 22 | @param version: The Juju version to use. | ||
298 | 23 | @param bindir: The directory containing the fake-juju binary. | ||
299 | 24 | This defaults to /usr/bin. | ||
300 | 25 | """ | ||
301 | 26 | if not version: | ||
302 | 27 | raise ValueError("version not provided") | ||
303 | 28 | filename = "fake-juju-{}".format(version) | ||
304 | 29 | if bindir is None: | ||
305 | 30 | # XXX Search $PATH. | ||
306 | 31 | bindir = "/usr/bin" | ||
307 | 32 | return os.path.join(bindir, filename) | ||
308 | 33 | |||
309 | 34 | |||
310 | 35 | def set_envvars(envvars, failures_filename=None, logsdir=None): | ||
311 | 36 | """Return the environment variables with which to run fake-juju. | ||
312 | 37 | |||
313 | 38 | @param envvars: The env dict to update. | ||
314 | 39 | @param failures_filename: The path to the failures file that | ||
315 | 40 | fake-juju will use. | ||
316 | 41 | @params logsdir: The path to the directory where fake-juju will | ||
317 | 42 | write its log files. | ||
318 | 43 | """ | ||
319 | 44 | envvars["FAKE_JUJU_FAILURES"] = failures_filename or "" | ||
320 | 45 | envvars["FAKE_JUJU_LOGS_DIR"] = logsdir or "" | ||
321 | 0 | 46 | ||
322 | === added directory 'python/fakejuju/tests' | |||
323 | === added file 'python/fakejuju/tests/__init__.py' | |||
324 | === added file 'python/fakejuju/tests/test_fakejuju.py' | |||
325 | --- python/fakejuju/tests/test_fakejuju.py 1970-01-01 00:00:00 +0000 | |||
326 | +++ python/fakejuju/tests/test_fakejuju.py 2016-10-06 22:15:11 +0000 | |||
327 | @@ -0,0 +1,130 @@ | |||
328 | 1 | # Copyright 2016 Canonical Limited. All rights reserved. | ||
329 | 2 | |||
330 | 3 | import unittest | ||
331 | 4 | |||
332 | 5 | import txjuju.cli | ||
333 | 6 | |||
334 | 7 | from fakejuju.fakejuju import get_bootstrap_spec, get_filename, set_envvars | ||
335 | 8 | |||
336 | 9 | |||
337 | 10 | class HelperTests(unittest.TestCase): | ||
338 | 11 | |||
339 | 12 | def test_get_bootstrap_spec_full(self): | ||
340 | 13 | """get_bootstrap_spec() works correctly when given all args.""" | ||
341 | 14 | spec = get_bootstrap_spec("my-env", "pw") | ||
342 | 15 | |||
343 | 16 | self.assertEqual( | ||
344 | 17 | spec, | ||
345 | 18 | txjuju.cli.BootstrapSpec("my-env", "dummy", admin_secret="pw")) | ||
346 | 19 | |||
347 | 20 | def test_get_bootstrap_spec_minimal(self): | ||
348 | 21 | """get_bootstrap_spec() works correctly when given minimal args.""" | ||
349 | 22 | spec = get_bootstrap_spec("my-env") | ||
350 | 23 | |||
351 | 24 | self.assertEqual(spec, txjuju.cli.BootstrapSpec("my-env", "dummy")) | ||
352 | 25 | |||
353 | 26 | def test_get_filename_full(self): | ||
354 | 27 | """get_filename() works correctly when given all args.""" | ||
355 | 28 | filename = get_filename("1.25.6", "/spam") | ||
356 | 29 | |||
357 | 30 | self.assertEqual(filename, "/spam/fake-juju-1.25.6") | ||
358 | 31 | |||
359 | 32 | def test_get_filename_minimal(self): | ||
360 | 33 | """get_filename() works correctly when given minimal args.""" | ||
361 | 34 | filename = get_filename("1.25.6") | ||
362 | 35 | |||
363 | 36 | self.assertEqual(filename, "/usr/bin/fake-juju-1.25.6") | ||
364 | 37 | |||
365 | 38 | def test_get_filename_empty_bindir(self): | ||
366 | 39 | """get_filename() works correctly when given an empty string | ||
367 | 40 | for bindir.""" | ||
368 | 41 | filename = get_filename("1.25.6", "") | ||
369 | 42 | |||
370 | 43 | self.assertEqual(filename, "fake-juju-1.25.6") | ||
371 | 44 | |||
372 | 45 | def test_get_filename_missing_version(self): | ||
373 | 46 | """get_filename() fails if version is None or empty.""" | ||
374 | 47 | with self.assertRaises(ValueError): | ||
375 | 48 | get_filename(None) | ||
376 | 49 | with self.assertRaises(ValueError): | ||
377 | 50 | get_filename("") | ||
378 | 51 | |||
379 | 52 | def test_set_envvars_full(self): | ||
380 | 53 | """set_envvars() works correctly when given all args.""" | ||
381 | 54 | envvars = {} | ||
382 | 55 | set_envvars(envvars, "/spam/failures", "/eggs/logsdir") | ||
383 | 56 | |||
384 | 57 | self.assertEqual(envvars, { | ||
385 | 58 | "FAKE_JUJU_FAILURES": "/spam/failures", | ||
386 | 59 | "FAKE_JUJU_LOGS_DIR": "/eggs/logsdir", | ||
387 | 60 | }) | ||
388 | 61 | |||
389 | 62 | def test_set_envvars_minimal(self): | ||
390 | 63 | """set_envvars() works correctly when given minimal args.""" | ||
391 | 64 | envvars = {} | ||
392 | 65 | set_envvars(envvars) | ||
393 | 66 | |||
394 | 67 | self.assertEqual(envvars, { | ||
395 | 68 | "FAKE_JUJU_FAILURES": "", | ||
396 | 69 | "FAKE_JUJU_LOGS_DIR": "", | ||
397 | 70 | }) | ||
398 | 71 | |||
399 | 72 | def test_set_envvars_start_empty(self): | ||
400 | 73 | """set_envvars() sets all values on an empty dict.""" | ||
401 | 74 | envvars = {} | ||
402 | 75 | set_envvars(envvars, "x", "y") | ||
403 | 76 | |||
404 | 77 | self.assertEqual(envvars, { | ||
405 | 78 | "FAKE_JUJU_FAILURES": "x", | ||
406 | 79 | "FAKE_JUJU_LOGS_DIR": "y", | ||
407 | 80 | }) | ||
408 | 81 | |||
409 | 82 | def test_set_envvars_no_collisions(self): | ||
410 | 83 | """set_envvars() sets all values when none are set yet.""" | ||
411 | 84 | envvars = {"SPAM": "eggs"} | ||
412 | 85 | set_envvars(envvars, "x", "y") | ||
413 | 86 | |||
414 | 87 | self.assertEqual(envvars, { | ||
415 | 88 | "SPAM": "eggs", | ||
416 | 89 | "FAKE_JUJU_FAILURES": "x", | ||
417 | 90 | "FAKE_JUJU_LOGS_DIR": "y", | ||
418 | 91 | }) | ||
419 | 92 | |||
420 | 93 | def test_set_envvars_empty_to_nonempty(self): | ||
421 | 94 | """set_envvars() updates empty values.""" | ||
422 | 95 | envvars = { | ||
423 | 96 | "FAKE_JUJU_FAILURES": "", | ||
424 | 97 | "FAKE_JUJU_LOGS_DIR": "", | ||
425 | 98 | } | ||
426 | 99 | set_envvars(envvars, "x", "y") | ||
427 | 100 | |||
428 | 101 | self.assertEqual(envvars, { | ||
429 | 102 | "FAKE_JUJU_FAILURES": "x", | ||
430 | 103 | "FAKE_JUJU_LOGS_DIR": "y", | ||
431 | 104 | }) | ||
432 | 105 | |||
433 | 106 | def test_set_envvars_nonempty_to_nonempty(self): | ||
434 | 107 | """set_envvars() overwrites existing values.""" | ||
435 | 108 | envvars = { | ||
436 | 109 | "FAKE_JUJU_FAILURES": "spam", | ||
437 | 110 | "FAKE_JUJU_LOGS_DIR": "ham", | ||
438 | 111 | } | ||
439 | 112 | set_envvars(envvars, "x", "y") | ||
440 | 113 | |||
441 | 114 | self.assertEqual(envvars, { | ||
442 | 115 | "FAKE_JUJU_FAILURES": "x", | ||
443 | 116 | "FAKE_JUJU_LOGS_DIR": "y", | ||
444 | 117 | }) | ||
445 | 118 | |||
446 | 119 | def test_set_envvars_nonempty_to_empty(self): | ||
447 | 120 | """set_envvars() with no args "unsets" existing values.""" | ||
448 | 121 | envvars = { | ||
449 | 122 | "FAKE_JUJU_FAILURES": "x", | ||
450 | 123 | "FAKE_JUJU_LOGS_DIR": "y", | ||
451 | 124 | } | ||
452 | 125 | set_envvars(envvars) | ||
453 | 126 | |||
454 | 127 | self.assertEqual(envvars, { | ||
455 | 128 | "FAKE_JUJU_FAILURES": "", | ||
456 | 129 | "FAKE_JUJU_LOGS_DIR": "", | ||
457 | 130 | }) | ||
458 | 0 | 131 | ||
459 | === added file 'python/setup.py' | |||
460 | --- python/setup.py 1970-01-01 00:00:00 +0000 | |||
461 | +++ python/setup.py 2016-10-06 22:15:11 +0000 | |||
462 | @@ -0,0 +1,69 @@ | |||
463 | 1 | import os | ||
464 | 2 | from importlib import import_module | ||
465 | 3 | try: | ||
466 | 4 | from setuptools import setup | ||
467 | 5 | except ImportError: | ||
468 | 6 | from distutils.core import setup | ||
469 | 7 | |||
470 | 8 | |||
471 | 9 | basedir = os.path.abspath(os.path.dirname(__file__) or '.') | ||
472 | 10 | |||
473 | 11 | # required data | ||
474 | 12 | |||
475 | 13 | package_name = 'fakejuju' | ||
476 | 14 | NAME = package_name | ||
477 | 15 | SUMMARY = 'A limited adaptation of Juju\'s client, with testing hooks.' | ||
478 | 16 | AUTHOR = 'Canonical Landscape team' | ||
479 | 17 | EMAIL = 'juju@lists.ubuntu.com' | ||
480 | 18 | PROJECT_URL = 'https://launchpad.net/fake-juju' | ||
481 | 19 | LICENSE = 'LGPLv3' | ||
482 | 20 | |||
483 | 21 | with open(os.path.join(basedir, 'README.md')) as readme_file: | ||
484 | 22 | DESCRIPTION = readme_file.read() | ||
485 | 23 | |||
486 | 24 | # dymanically generated data | ||
487 | 25 | |||
488 | 26 | VERSION = import_module(package_name).__version__ | ||
489 | 27 | |||
490 | 28 | # set up packages | ||
491 | 29 | |||
492 | 30 | exclude_dirs = [ | ||
493 | 31 | 'tests', | ||
494 | 32 | ] | ||
495 | 33 | |||
496 | 34 | PACKAGES = [] | ||
497 | 35 | for path, dirs, files in os.walk(package_name): | ||
498 | 36 | if "__init__.py" not in files: | ||
499 | 37 | continue | ||
500 | 38 | path = path.split(os.sep) | ||
501 | 39 | if path[-1] in exclude_dirs: | ||
502 | 40 | continue | ||
503 | 41 | PACKAGES.append(".".join(path)) | ||
504 | 42 | |||
505 | 43 | # dependencies | ||
506 | 44 | |||
507 | 45 | DEPS = ['yaml', | ||
508 | 46 | # for testing | ||
509 | 47 | 'txjuju', | ||
510 | 48 | 'fixtures', | ||
511 | 49 | 'testtools', | ||
512 | 50 | ] | ||
513 | 51 | |||
514 | 52 | |||
515 | 53 | if __name__ == "__main__": | ||
516 | 54 | setup(name=NAME, | ||
517 | 55 | version=VERSION, | ||
518 | 56 | author=AUTHOR, | ||
519 | 57 | author_email=EMAIL, | ||
520 | 58 | url=PROJECT_URL, | ||
521 | 59 | license=LICENSE, | ||
522 | 60 | description=SUMMARY, | ||
523 | 61 | long_description=DESCRIPTION, | ||
524 | 62 | packages=PACKAGES, | ||
525 | 63 | |||
526 | 64 | # for distutils | ||
527 | 65 | requires=DEPS, | ||
528 | 66 | |||
529 | 67 | # for setuptools | ||
530 | 68 | install_requires=DEPS, | ||
531 | 69 | ) |
Command: make ci-test /ci.lscape. net/job/ latch-test- xenial/ 15/
Result: Success
Revno: 42
Branch: lp:~ericsnowcurrently/fake-juju/python-lib-helpers
Jenkins: https:/