Fix unit tests for elements
It looks like we dropped running these probably when we moved the elements around. For testtools to find the test scripts we need to add the __init__.py files to make the directories look like modules. Also prevent copying any .pyc or cache files in as hooks. Change-Id: I66d5f6ee62cc4d9ee14c64e819b4db57d035d09f
This commit is contained in:
parent
bc6f9f64d8
commit
0da1d3a419
0
diskimage_builder/elements/__init__.py
Normal file
0
diskimage_builder/elements/__init__.py
Normal file
@ -27,15 +27,15 @@ class TestCacheUrl(base.ScriptTestBase):
|
||||
source = 'http://fake/url'
|
||||
# Write fake data to the target file and return success
|
||||
self._stub_script('curl', 'echo "test" > ${3:7:100}\necho 200')
|
||||
self._run_command(['elements/cache-url/bin/cache-url',
|
||||
source,
|
||||
target])
|
||||
self._run_command(
|
||||
['diskimage_builder/elements/cache-url/bin/cache-url',
|
||||
source, target])
|
||||
self.assertTrue(os.path.exists(target))
|
||||
modification_time = os.path.getmtime(target)
|
||||
# Make sure that the timestamp would change if the file does
|
||||
time.sleep(1)
|
||||
self._stub_script('curl', 'echo "304"')
|
||||
self._run_command(['elements/cache-url/bin/cache-url',
|
||||
source,
|
||||
target])
|
||||
self._run_command(
|
||||
['diskimage_builder/elements/cache-url/bin/cache-url',
|
||||
source, target])
|
||||
self.assertEqual(modification_time, os.path.getmtime(target))
|
||||
|
0
diskimage_builder/elements/svc-map/__init__.py
Normal file
0
diskimage_builder/elements/svc-map/__init__.py
Normal file
@ -111,11 +111,15 @@ function generate_hooks () {
|
||||
|
||||
for dir in $(find $element_dir \
|
||||
-follow -mindepth 1 -maxdepth 1 \
|
||||
-type d -not -name tests); do
|
||||
-type d \
|
||||
-not -name tests \
|
||||
-not -name __pycache__); do
|
||||
copy_hooks_not_overwrite $dir
|
||||
done
|
||||
for file in $(find $element_dir \
|
||||
-follow -maxdepth 1 -type f); do
|
||||
-follow -maxdepth 1 \
|
||||
-type f \
|
||||
-not -name '*.pyc'); do
|
||||
cp -t $TMP_HOOKS_PATH -a $file
|
||||
done
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user