def test_setting_author_writes_it_to_file(self, mock_write_lines, _1, _2): new_content = list(DEFAULT_CONFIG_RESPONSE) new_content[-1] = '\temail = new_email@localhost' new_content[-2] = '\tname = new_name' git = Git(self.path_to_git) git.author = Author(name='new_name', email='new_email@localhost') mock_write_lines.assert_called_with(self.path_to_git.joinpath('config'), new_content)
def test_setting_writes_author_when_no_author_currently_present(self, mock_write_lines, _1, _2): content_without_author = list(DEFAULT_CONFIG_RESPONSE) del content_without_author[-1] del content_without_author[-1] del content_without_author[-1] new_content = content_without_author + [ '[user]', '\tname = new_name', '\temail = new_email@localhost' ] git = Git(self.path_to_git) git._config_lines = content_without_author git.author = Author(name='new_name', email='new_email@localhost') mock_write_lines.assert_called_with(self.path_to_git.joinpath('config'), new_content)