~openstack-charmers-next/charms/wily/swift-proxy/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_swift_context.py

  • Committer: James Page
  • Date: 2016-05-23 09:08:57 UTC
  • Revision ID: james.page@ubuntu.com-20160523090857-857yk8sjk9atjmb0
Use JUJU_MODEL_UUID for Juju 2.0

Juju 2.0 renames the environment variable JUJU_ENV_UUID
to JUJU_MODEL_UUID; use this environment variable as a
fallback if JUJU_ENV_UUID is not set to support Juju 2.0,
whilst continuing to provide support for Juju < 2.0.

Change-Id: I26ae366c84d3cd9a9c2471385effd2a6202e9314
Closes-Bug: 1572575

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        with mock.patch('lib.swift_context.os.environ.get') as mock_env_get:
49
49
            mock_env_get.return_value = str(uuid.uuid4())
50
50
            hash_ = swift_context.get_swift_hash()
51
 
            mock_env_get.assert_called_with('JUJU_ENV_UUID')
 
51
            mock_env_get.assert_has_calls([
 
52
                mock.call('JUJU_MODEL_UUID'),
 
53
                mock.call('JUJU_ENV_UUID',
 
54
                          mock_env_get.return_value)
 
55
            ])
52
56
 
53
57
        with open(tmpfile, 'r') as fd:
54
58
            self.assertEqual(hash_, fd.read())