summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_gce.py
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-04-20 11:52:50 +0100
committerDaniel Watkins <daniel.watkins@canonical.com>2015-04-20 11:52:50 +0100
commit3551333795539c2cec1195841d2a641046981ba6 (patch)
tree0413b8f092f836f244813556dbf8c2a12312ace5 /tests/unittests/test_datasource/test_gce.py
parent341a805fca9a06ce12e9f4bbbe15b3dded9eb6a4 (diff)
downloadvyos-cloud-init-3551333795539c2cec1195841d2a641046981ba6.tar.gz
vyos-cloud-init-3551333795539c2cec1195841d2a641046981ba6.zip
Add test that missing GCE required key returns False.
Diffstat (limited to 'tests/unittests/test_datasource/test_gce.py')
-rw-r--r--tests/unittests/test_datasource/test_gce.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_gce.py b/tests/unittests/test_datasource/test_gce.py
index 4280abc4..540a55d0 100644
--- a/tests/unittests/test_datasource/test_gce.py
+++ b/tests/unittests/test_datasource/test_gce.py
@@ -141,3 +141,14 @@ class TestDataSourceGCE(test_helpers.HttprettyTestCase):
decoded = b64decode(
GCE_META_ENCODING.get('instance/attributes/user-data'))
self.assertEqual(decoded, self.ds.get_userdata_raw())
+
+ @httpretty.activate
+ def test_missing_required_keys_return_false(self):
+ for required_key in ['instance/id', 'instance/zone',
+ 'instance/hostname']:
+ meta = GCE_META_PARTIAL.copy()
+ del meta[required_key]
+ httpretty.register_uri(httpretty.GET, MD_URL_RE,
+ body=_new_request_callback(meta))
+ self.assertEqual(False, self.ds.get_data())
+ httpretty.reset()