Esempio n. 1
0
 def test_generate(self, mock_safe_dump, mock_bed):
     mock_args = mock.Mock()
     mock_args.id = 'foo'
     mock_args.env = ['foo.yaml']
     mock_bed.return_value = yaml.safe_load(test_env)
     path = deploy._generate_id_env(mock_args)
     self.assertEqual(['foo.yaml', 'env-foo.yaml'], path)
     dumped_dict = mock_safe_dump.call_args_list[0][0][0]
     for k, v in test_env_output.items():
         self.assertEqual(v, dumped_dict['parameter_defaults'][k])
Esempio n. 2
0
 def test_generate(self, mock_safe_dump):
     mock_args = mock.Mock()
     mock_args.id = 'foo'
     with mock.patch('openstack_virtual_baremetal.deploy.open',
                     mock.mock_open(read_data=test_env),
                     create=True) as mock_open:
         path = deploy._generate_id_env(mock_args)
         self.assertEqual('env-foo.yaml', path)
         mock_safe_dump.assert_called_once_with(test_env_output,
                                                mock.ANY,
                                                default_flow_style=False)
Esempio n. 3
0
 def test_generate_undercloud_name(self, mock_safe_dump):
     mock_args = mock.Mock()
     mock_args.id = 'foo'
     env = test_env + '  undercloud_name: undercloud\n'
     env_output = dict(test_env_output)
     env_output['parameters']['undercloud_name'] = 'undercloud-foo'
     with mock.patch('openstack_virtual_baremetal.deploy.open',
                     mock.mock_open(read_data=env),
                     create=True) as mock_open:
         path = deploy._generate_id_env(mock_args)
         self.assertEqual('env-foo.yaml', path)
         mock_safe_dump.assert_called_once_with(env_output,
                                                mock.ANY,
                                                default_flow_style=False)
Esempio n. 4
0
 def test_generate_with_role(self, mock_safe_dump, mock_bed):
     mock_args = mock.Mock()
     mock_args.id = 'foo'
     mock_args.env = ['foo.yaml']
     env = (test_env + test_env_extra)
     mock_bed.return_value = yaml.safe_load(env)
     mock_bed.return_value['parameter_defaults']['role'] = 'compute'
     env_output = dict(test_env_output)
     env_output['overcloud_internal_net'] = 'internalapi-foo'
     env_output['baremetal_prefix'] = 'baremetal-foo-compute'
     path = deploy._generate_id_env(mock_args)
     self.assertEqual(['foo.yaml', 'env-foo.yaml'], path)
     dumped_dict = mock_safe_dump.call_args_list[0][0][0]
     for k, v in env_output.items():
         self.assertEqual(v, dumped_dict['parameter_defaults'][k])
Esempio n. 5
0
 def test_generate_undercloud_name(self, mock_safe_dump, mock_bed):
     mock_args = mock.Mock()
     mock_args.id = 'foo'
     mock_args.env = ['foo.yaml']
     env = (test_env + test_env_extra +
            '  undercloud_name: test-undercloud\n')
     mock_bed.return_value = yaml.safe_load(env)
     env_output = dict(test_env_output)
     env_output['undercloud_name'] = 'test-undercloud-foo'
     env_output['overcloud_internal_net'] = 'internalapi-foo'
     path = deploy._generate_id_env(mock_args)
     self.assertEqual(['foo.yaml', 'env-foo.yaml'], path)
     dumped_dict = mock_safe_dump.call_args_list[0][0][0]
     for k, v in env_output.items():
         self.assertEqual(v, dumped_dict['parameter_defaults'][k])