From 128bce8fff491f880089569f5922405a881018d8 Mon Sep 17 00:00:00 2001 From: Rory Finnegan Date: Wed, 30 Apr 2014 14:49:26 -0500 Subject: [PATCH] Added manifest checking tests. Overview: 1) fixed up .gitignore file to use absolute paths (to project dir). 2) updated tox to run both manifest tests and flake8 3) updated yml file cause NULL for aws credentials causes an error on validation. 4) actually added the tests under tests/integration --- .gitignore | 14 +++---- README.md | 1 - ...-ebs-debian-testing-amd64-pvm.manifest.yml | 4 +- tests/integration/manifests_tests.py | 39 +++++++++++++++++++ tox.ini | 10 +++-- 5 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 tests/integration/manifests_tests.py diff --git a/.gitignore b/.gitignore index f252264..ac36a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,14 @@ *.pyc # Jekyll-generated files -Gemfile.lock -_site/ +/Gemfile.lock +/_site/ # When developing for ec2 `vagrant provision' is quite handy /Vagrantfile -/.vagrant +/.vagrant/ # Building the package -/build -/dist -/bootstrap_vz.egg-info +/build/ +/dist/ +/bootstrap_vz.egg-info/ # Testing /.coverage -/.tox +/.tox/ diff --git a/README.md b/README.md index f6a2a9a..9747034 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ bootstrap-vz =========================================== - bootstrap-vz is a bootstrapping framework for Debian. It is is specifically targeted at bootstrapping systems for virtualized environments. bootstrap-vz runs without any user intervention and generates ready-to-boot images for diff --git a/manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml b/manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml index 43f44b0..cfdbd73 100644 --- a/manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml +++ b/manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml @@ -2,8 +2,8 @@ provider: "ec2" virtualization: "pvm" credentials: - access-key: null - secret-key: null + access-key: "" + secret-key: "" bootstrapper: workspace: "/target" image: diff --git a/tests/integration/manifests_tests.py b/tests/integration/manifests_tests.py new file mode 100644 index 0000000..74a89d7 --- /dev/null +++ b/tests/integration/manifests_tests.py @@ -0,0 +1,39 @@ +import os +from nose.tools import assert_true +from bootstrapvz.base.manifest import Manifest + +MANIFEST_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + '../../manifests' +) + + +def test_manifest_generator(): + """ + manifests_tests - test_manifest_generator. + + Loops through the manifests directory and tests that + each file can successfully be loaded and validated. + """ + for fobj in os.listdir(MANIFEST_DIR): + path = os.path.join(os.path.abspath(MANIFEST_DIR), fobj) + + yield validate_manifests, path + + +def validate_manifests(path): + """ + manifests_tests - validate_manifests. + + Actually creates the manifest for a given path + and checks that all the data values have successfully + been created. + """ + manifest = Manifest(path) + + assert_true(manifest.data) + assert_true(manifest.data['provider']) + assert_true(manifest.data['bootstrapper']) + assert_true(manifest.data['image']) + assert_true(manifest.data['volume']) + assert_true(manifest.data['system']) diff --git a/tox.ini b/tox.ini index b7ba5b1..b4a76b4 100644 --- a/tox.ini +++ b/tox.ini @@ -3,12 +3,14 @@ ignore = E101,E221,E241,E501,W191 max-line-length = 110 [tox] -envlist = flake8 +envlist = flake8, integration [testenv:flake8] deps = flake8 commands = flake8 bootstrapvz/ --exclude=minify_json.py -# Once tests have started being written, uncomment this to run tests when running tox. -#[testenv] -#commands = nosetests -v tests --with-coverage --cover-package=bootstrapvz --cover-inclusive +[testenv:integration] +deps = + nose + nose-cov +commands = nosetests -v tests/integration --with-coverage --cover-package=bootstrapvz --cover-inclusive