def test_loadYaml_shouldReturnEmptyDefaultContextIfNotExists(mockexists): fake_config_file = 'README.md' mockexists.return_value = False actual = cookie_cutter_interface.loadYamlFile(fake_config_file) assert actual == {'default_context': {} } mockexists.assert_called_once_with(fake_config_file)
def test_loadYaml_shouldReturnEmptyDefaultContextIfNone(mockexists, mockYamlLoad): fake_config_file = 'README.md' mockexists.return_value = True mockYamlLoad.return_value = None mockOpen = mock_open(read_data=fake_config_file) with patch('__main__.open', mockOpen): actual = cookie_cutter_interface.loadYamlFile(fake_config_file) assert actual == {'default_context': {} }
def test_loadYaml_shouldLoadFromYamlFile(mockexists, mockYamlLoad): fake_yaml_context = {'default_context': { "foo": "bar"}} fake_config_file = 'README.md' mockexists.return_value = True mockYamlLoad.return_value = fake_yaml_context mockOpen = mock_open(read_data=fake_config_file) with patch('__main__.open', mockOpen): actual = cookie_cutter_interface.loadYamlFile(fake_config_file) assert actual == fake_yaml_context