juju-solutions / layer-cwr

Layer for building the Juju Jenkins CI env
Other
2 stars 5 forks source link

cwr layer unit test failure #113

Closed kwmonroe closed 7 years ago

kwmonroe commented 7 years ago

I think you'll need to mock out the activate_venv when testing the s3 bits. Otherwise, cwrhelpers.py is gonna try to pull in lib/charms/layer/basic.py, which doesn't exist in the layer source. You'll only get that in the built charm.

$ make unit_test
...
py35 runtests: commands[0] | python3 -m nose ./unit_tests -v
test_bundle (test_bundlebuilder.TestBundlebuilder) ... ok
test_charm (test_bundlebuilder.TestBundlebuilder) ... ok
test_execute (test_bundlebuilder.TestBundlebuilder) ... ok
test_help (test_bundlebuilder.TestBundlebuilder) ... ok
test_raise (test_bundlebuilder.TestBundlebuilder) ... ok
Failure: ImportError (No module named 'charms.layer') ... ERROR

======================================================================
ERROR: Failure: ImportError (No module named 'charms.layer')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/home/ubuntu/charms/layers/layer-cwr/.tox/py35/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/ubuntu/charms/layers/layer-cwr/unit_tests/test_cwrhelpers.py", line 14, in <module>
    from actions.cwrhelpers import get_s3_credentials
  File "/home/ubuntu/charms/layers/layer-cwr/actions/cwrhelpers.py", line 9, in <module>
    from charms.layer.basic import activate_venv  # noqa: E402
ImportError: No module named 'charms.layer'

----------------------------------------------------------------------
Ran 6 tests in 2.112s

FAILED (errors=1)
ERROR: InvocationError: '/home/ubuntu/charms/layers/layer-cwr/.tox/py35/bin/python3 -m nose ./unit_tests -v'
____________________________________________________________________________________ summary ____________________________________________________________________________________
SKIPPED:  py34: InterpreterNotFound: python3.4
ERROR:   py35: commands failed
Makefile:22: recipe for target 'unit_test' failed
make: *** [unit_test] Error 1
kwmonroe commented 7 years ago

FYI, i'm tagging this as a high bug because it's causing travis to fail.

kwmonroe commented 7 years ago

Fixed with https://github.com/juju-solutions/layer-cwr/commit/0b964675d64abe415a59ba16faae8e295f1a0e44