66
68
super(FakeHomeTestCase, self).setUp()
67
69
self.home_dir = use_context(self, utility.temp_dir())
68
os.environ["HOME"] = self.home_dir
69
os.environ["PATH"] = os.path.join(self.home_dir, ".local", "bin")
70
os.mkdir(os.path.join(self.home_dir, ".juju"))
70
os.environ['HOME'] = self.home_dir
71
os.environ['PATH'] = os.path.join(self.home_dir, '.local', 'bin')
72
os.mkdir(os.path.join(self.home_dir, '.juju'))
73
self.set_public_clouds(get_default_public_clouds())
75
def set_public_clouds(self, data_dict):
76
"""Set the data in the public-clouds.yaml file.
78
:param data_dict: A dictionary of data, which is used to overwrite
79
the data in public-clouds.yaml, or None, in which case the file
81
dest_file = os.path.join(self.home_dir, '.juju/public-clouds.yaml')
85
except OSError as error:
86
if error.errno != errno.ENOENT:
89
with open(dest_file, 'w') as file:
90
yaml.safe_dump(data_dict, file)
73
93
def setup_test_logging(testcase, level=None):
105
125
os.environ[key] = org_value
128
def get_default_public_clouds():
129
"""The dict used to fill public-clouds.yaml by FakeHomeTestCase."""
134
'auth-types': ['access-key'],
136
# This is the fake juju endpoint:
137
'bar': {'endpoint': 'bar.foo.example.com'},
138
'fee': {'endpoint': 'fee.foo.example.com'},
139
'fi': {'endpoint': 'fi.foo.example.com'},
140
'foe': {'endpoint': 'foe.foo.example.com'},
141
'fum': {'endpoint': 'fum.foo.example.com'},
146
'auth-types': ['access-key'],
148
'north': {'endpoint': 'north.qux.example.com'},
149
'south': {'endpoint': 'south.qux.example.com'},