Merge ~chad.smith/cloud-init:unittest-oauthlib-import into cloud-init:master
| Status: | Merged |
|---|---|
| Approved by: | Scott Moser on 2017-08-30 |
| Approved revision: | b1a44ee8f90214d348198c6bd81288e4888acbef |
| Merged at revision: | b931a6473ee929193c0048640bf34876ce831a15 |
| Proposed branch: | ~chad.smith/cloud-init:unittest-oauthlib-import |
| Merge into: | cloud-init:master |
| Diff against target: |
79 lines (+43/-7) 3 files modified
cloudinit/tests/__init__.py (+0/-0) cloudinit/tests/test_url_helper.py (+40/-0) cloudinit/url_helper.py (+3/-7) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Scott Moser | 2017-08-30 | Approve on 2017-08-30 | |
| Server Team CI bot | continuous-integration | Approve on 2017-08-30 | |
|
Review via email:
|
|||
Description of the Change
url_helper: dynamically import oauthlib import from inside oauth_headers
oauth_headers is the only function which requires oauthlib, move the
import and ImportError handling inside this function to only attempt
loading at runtime if called. This will allow us to build on platforms
that don't have python-oauthlib installed by default. Add simple unittests
around the missing oauthlib dependencies to make sure the function
performs as intended and raises and NotImplementedError if oauthlib can't
be imported.
- b1a44ee... by Chad Smith on 2017-08-30
PASSED: Continuous integration, rev:b1a44ee8f90
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
I approve.
the removal of the single time 'import' does make it somewhat slower, but oh well.
>>> timeit.
0.2964163040742278
>>> timeit.
0.531060776906088
so its not all that bad. (that is 1M runs).
| Scott Moser (smoser) wrote : | # |
i further realized that my timeit didnt make any sense.
I was only testing the positive path. So that is slightly slower than comparing a boolean.
The "not available" path would probably be much slower, but we're not really ever going to be in a loop on that because the NotImplementedError will raise exception.
So... Approve. and I'll grab.


FAILED: Continuous integration, rev:87973cd2f2b baed380c01dbb08 2246d90a76446d /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 226/
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 226/rebuild
https:/