From f46a162ea225d4a962977120ad3f4bdb01777cad Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Wed, 6 Jul 2016 16:56:19 -0700 Subject: [PATCH] Add basic test coverage for build_spec This asserts the basic public surface area of the module Change-Id: I97f5f228ed55dd0d0b748a47bd88c72c55500102 --- giftwrap/tests/test_buildspec.py | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 giftwrap/tests/test_buildspec.py diff --git a/giftwrap/tests/test_buildspec.py b/giftwrap/tests/test_buildspec.py new file mode 100644 index 0000000..d79eeaa --- /dev/null +++ b/giftwrap/tests/test_buildspec.py @@ -0,0 +1,61 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014, John Dewey +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import tempfile +import unittest2 as unittest + +import yaml + +from giftwrap import build_spec +from giftwrap.settings import Settings + + +class TestBuildSpec(unittest.TestCase): + + def test_build_spec(self): + manifest = { + 'settings': {}, + } + with tempfile.TemporaryFile(mode='w+') as tf: + version = '0' + yaml.safe_dump(manifest, tf) + tf.flush() + tf.seek(0) + bs = build_spec.BuildSpec(tf, version) + self.assertTrue(isinstance(bs.settings, Settings)) + + def test_build_spec_projects(self): + manifest = { + 'settings': {}, + 'projects': [ + { + 'name': 'project1', + }, + { + 'name': 'project2', + }, + ], + } + with tempfile.TemporaryFile(mode='w+') as tf: + version = '99' + yaml.safe_dump(manifest, tf) + tf.flush() + tf.seek(0) + bs = build_spec.BuildSpec(tf, version) + self.assertEqual(2, len(bs.projects)) + for project in bs.projects: + self.assertEqual('99', project.version)