예제 #1
0
    def test_read_discovered_file(self, mock_config_finder_class):
        config_path = self.test_helper.prepare_file('simple-config')
        mock_config_finder_inst = mock_config_finder_class.return_value
        mock_config_finder_inst.find.return_value = config_path

        config_io = ConfigIO()
        config, found_path = config_io.read_discovered_file()
        mock_config_finder_inst.find.assert_called_once()

        # Check config
        self.assertEqual(found_path, config_path)
        self.assertEqual(len(config.environments), 2)
        self.assertIn('test', config.environments)
        test_env = config.environments['test']
        self.assertIsInstance(test_env, EnvironmentGroup)
        self.assertIsInstance(test_env.lm, TNCOEnvironment)
        self.assertEqual(test_env.lm.address, 'https://127.0.0.1:1111')
        self.assertEqual(test_env.lm.auth_address, 'http://auth:4643')
        self.assertEqual(test_env.lm.username, 'jack')
        self.assertEqual(test_env.lm.password, 'secret')
        self.assertEqual(test_env.lm.kami_address, 'https://127.0.0.1:34567')
        arms_config = test_env.arms
        self.assertEqual(len(arms_config), 1)
        default_arm_config = arms_config['default']
        self.assertIsInstance(default_arm_config, ArmEnvironment)
        self.assertEqual(default_arm_config.address, 'http://default:8765')
        self.assertIn('test2', config.environments)
        test2_env = config.environments['test2']
        arms_config = test2_env.arms
        self.assertEqual(len(arms_config), 2)
        self.assertIn('first', arms_config)
        self.assertIn('second', arms_config)
예제 #2
0
    def test_read_discovered_file_override_path(self,
                                                mock_config_finder_class):
        config_path = self.test_helper.prepare_file('simple-config')
        mock_config_finder_inst = mock_config_finder_class.return_value

        config_io = ConfigIO()
        config, found_path = config_io.read_discovered_file(
            override_path=config_path)
        mock_config_finder_inst.find.assert_not_called()

        # Brief check that config loaded
        self.assertEqual(found_path, config_path)
        self.assertIn('test', config.environments)