blob: 955f8dfac4d8c32e804fe573fc02c06e44272509 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# This file is part of cloud-init. See LICENSE file for license information.
"""Tests of the built-in user data handlers."""
import os
from . import helpers as test_helpers
from cloudinit import sources
class MyDataSource(sources.DataSource):
_instance_id = None
def get_instance_id(self):
return self._instance_id
class TestPaths(test_helpers.ResourceUsingTestCase):
def test_get_ipath_and_instance_id_with_slashes(self):
myds = MyDataSource(sys_cfg={}, distro=None, paths={})
myds._instance_id = "/foo/bar"
safe_iid = "_foo_bar"
mypaths = self.getCloudPaths(myds)
self.assertEqual(
os.path.join(mypaths.cloud_dir, 'instances', safe_iid),
mypaths.get_ipath())
def test_get_ipath_and_empty_instance_id_returns_none(self):
myds = MyDataSource(sys_cfg={}, distro=None, paths={})
myds._instance_id = None
mypaths = self.getCloudPaths(myds)
self.assertEqual(None, mypaths.get_ipath())
# vi: ts=4 expandtab
|