def test_false_on_unknown_string(self, m_read_dmi_data): """Should return false on an unrelated string.""" m_read_dmi_data.return_value = "cubs win" ret = ay._is_aliyun() self.assertEqual(self.read_dmi_data_expected, m_read_dmi_data.call_args_list) self.assertEqual(False, ret)
def setUp(self): super(TestAliYunDatasource, self).setUp() cfg = {'datasource': {'AliYun': {'timeout': '1', 'max_wait': '1'}}} distro = {} paths = helpers.Paths({'run_dir': self.tmp_dir()}) self.ds = ay.DataSourceAliYun(cfg, distro, paths) self.metadata_address = self.ds.metadata_urls[0]
def test_true_on_aliyun_product(self, m_read_dmi_data): """Should return true if the dmi product data has expected value.""" m_read_dmi_data.return_value = self.ALIYUN_PRODUCT ret = ay._is_aliyun() self.assertEqual(self.read_dmi_data_expected, m_read_dmi_data.call_args_list) self.assertEqual(True, ret)
def test_false_on_empty_string(self, m_read_dmi_data): """Should return false on empty value returned.""" m_read_dmi_data.return_value = "" ret = ay._is_aliyun() self.assertEqual(self.read_dmi_data_expected, m_read_dmi_data.call_args_list) self.assertEqual(False, ret)
def setUp(self): super(TestAliYunDatasource, self).setUp() cfg = {"datasource": {"AliYun": {"timeout": "1", "max_wait": "1"}}} distro = {} paths = helpers.Paths({"run_dir": self.tmp_dir()}) self.ds = ay.DataSourceAliYun(cfg, distro, paths) self.metadata_address = self.ds.metadata_urls[0]
def test_parse_public_keys(self): public_keys = {} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {'key-pair-0': 'ssh-key-0'} self.assertEqual(ay.parse_public_keys(public_keys), [public_keys['key-pair-0']]) public_keys = {'key-pair-0': 'ssh-key-0', 'key-pair-1': 'ssh-key-1'} self.assertEqual( set(ay.parse_public_keys(public_keys)), set([public_keys['key-pair-0'], public_keys['key-pair-1']])) public_keys = {'key-pair-0': ['ssh-key-0', 'ssh-key-1']} self.assertEqual(ay.parse_public_keys(public_keys), public_keys['key-pair-0']) public_keys = {'key-pair-0': {'openssh-key': []}} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {'key-pair-0': {'openssh-key': 'ssh-key-0'}} self.assertEqual(ay.parse_public_keys(public_keys), [public_keys['key-pair-0']['openssh-key']]) public_keys = { 'key-pair-0': { 'openssh-key': ['ssh-key-0', 'ssh-key-1'] } } self.assertEqual(ay.parse_public_keys(public_keys), public_keys['key-pair-0']['openssh-key'])
def test_parse_public_keys(self): public_keys = {} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {'key-pair-0': 'ssh-key-0'} self.assertEqual(ay.parse_public_keys(public_keys), [public_keys['key-pair-0']]) public_keys = {'key-pair-0': 'ssh-key-0', 'key-pair-1': 'ssh-key-1'} self.assertEqual(set(ay.parse_public_keys(public_keys)), set([public_keys['key-pair-0'], public_keys['key-pair-1']])) public_keys = {'key-pair-0': ['ssh-key-0', 'ssh-key-1']} self.assertEqual(ay.parse_public_keys(public_keys), public_keys['key-pair-0']) public_keys = {'key-pair-0': {'openssh-key': []}} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {'key-pair-0': {'openssh-key': 'ssh-key-0'}} self.assertEqual(ay.parse_public_keys(public_keys), [public_keys['key-pair-0']['openssh-key']]) public_keys = {'key-pair-0': {'openssh-key': ['ssh-key-0', 'ssh-key-1']}} self.assertEqual(ay.parse_public_keys(public_keys), public_keys['key-pair-0']['openssh-key'])
def test_parse_public_keys(self): public_keys = {} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {"key-pair-0": "ssh-key-0"} self.assertEqual(ay.parse_public_keys(public_keys), [public_keys["key-pair-0"]]) public_keys = {"key-pair-0": "ssh-key-0", "key-pair-1": "ssh-key-1"} self.assertEqual( set(ay.parse_public_keys(public_keys)), set([public_keys["key-pair-0"], public_keys["key-pair-1"]]), ) public_keys = {"key-pair-0": ["ssh-key-0", "ssh-key-1"]} self.assertEqual(ay.parse_public_keys(public_keys), public_keys["key-pair-0"]) public_keys = {"key-pair-0": {"openssh-key": []}} self.assertEqual(ay.parse_public_keys(public_keys), []) public_keys = {"key-pair-0": {"openssh-key": "ssh-key-0"}} self.assertEqual( ay.parse_public_keys(public_keys), [public_keys["key-pair-0"]["openssh-key"]], ) public_keys = { "key-pair-0": { "openssh-key": ["ssh-key-0", "ssh-key-1"] } } self.assertEqual( ay.parse_public_keys(public_keys), public_keys["key-pair-0"]["openssh-key"], )