Skip to content

Commit

Permalink
Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ijrsvt committed Dec 8, 2021
1 parent 6edde83 commit 00e616e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/contrib/test_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,19 @@ def test_custom_metadata_root_from_env(self):
self.assertEqual(http.requests, 1)
expected_uri = 'http://{}/computeMetadata/v1/'.format(fake_metadata_root)
self.assertEqual(http.uri, expected_uri)

def test_new_custom_metadata_host_from_env(self):
headers = {'content-type': 'application/json'}
http = http_mock.HttpMock(headers=headers, data='{}')
fake_metadata_root = 'another.metadata.service'
os.environ['GCE_METADATA_HOST'] = fake_metadata_root
reload_module(_metadata)
try:
_metadata.get(http, '')
finally:
del os.environ['GCE_METADATA_HOST']
reload_module(_metadata)
# Verify mock.
self.assertEqual(http.requests, 1)
expected_uri = 'http://{}/computeMetadata/v1/'.format(fake_metadata_root)
self.assertEqual(http.uri, expected_uri)

0 comments on commit 00e616e

Please sign in to comment.