コード例 #1
0
    def test_load_config_file_from_nonexisting_file(
            self, mock_load, mock_is_dir):
        mock_load.side_effect = IOError('Failed to load fake file')
        fake_path = os.path.join('path', 'to', 'some_file.ext')
        with self.assertRaises(IOError):
            config.load_config_file(fake_path)

        mock_load.assert_called_with(fake_path)
コード例 #2
0
    def test_load_config_file_from_directory_nonexisting(
            self, mock_load, mock_is_dir):
        mock_load.side_effect = IOError('Failed to load fake file')
        fake_path = os.path.join('path', 'to', 'directory')
        with self.assertRaises(ValueError):
            config.load_config_file(fake_path)

        mock_load.assert_has_calls([
            call(os.path.join(fake_path, '.s3_website.yaml')),
            call(os.path.join(fake_path, '.s3_website.yml'))
        ])
コード例 #3
0
    def test_load_config_file_from_absolute_path(self, mock_load, mock_is_dir):
        mocked_config_dict = {}
        mock_load.return_value = mocked_config_dict
        fake_path = os.path.join('path', 'to', 'some_file.ext')
        config_dict, base_path = config.load_config_file(fake_path)

        mock_load.assert_called_with(fake_path)
        self.assertEqual(config_dict, mocked_config_dict)
        self.assertEqual(base_path, os.path.join('path', 'to'))
コード例 #4
0
    def test_load_config_file_from_directory(self, mock_load, mock_is_dir):
        mocked_config_dict = {}
        mock_load.return_value = mocked_config_dict
        fake_path = os.path.join('path', 'to', 'some', 'directory')
        config_dict, base_path = config.load_config_file(fake_path)

        mock_load.assert_called_once_with(
            os.path.join(fake_path, '.s3_website.yaml'))
        self.assertEqual(config_dict, mocked_config_dict)
        self.assertEqual(base_path, fake_path)