redhat-imaging / novaimagebuilder

Image building tool for OpenStack.
Apache License 2.0
0 stars 1 forks source link

Refactoring: DRY up the code #3

Open steveloranz opened 10 years ago

steveloranz commented 10 years ago

The current tree was done as a POC and there are some redundant cut-and-pasted sections that could use some cleaning up.

steveloranz commented 10 years ago

@imcleod - I'm working with SHA: 3f2d0d9ac23b7cf55b6e1a975d013396df536f8e and seeing the following stack trace when running the test_cacheManager tests.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/case.py", line 369, in run
    testMethod()
  File "/usr/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/root/sloranz/src/novaimagebuilder/tests/test_cacheManager.py", line 25, in <module>
    sys.modules['StackEnvironment'] = sys.modules.pop('MockStackEnvironment')
KeyError: 'MockStackEnvironment'

Rather than messing with the loaded modules, I'm proposing that we change CacheManager so that one can set the stack environment. This requires no conditional logic in the CacheManager class or any other real class and is something that would be set by the unit test.

Comment?

steveloranz commented 10 years ago

This was dependent on the test runner being used. For whatever reason, I had PyCharm setup to use python unittest for all tests but nose for the single test. Switching to utrunner instead of noserunner fixed my issue without having to muck around with the python path.