def test_it_cannot_update_a_missing_git_module(): github_repository = MagicMock() content = github_repository.get_file_contents() content.decoded_content.decode.return_value = ('') puppetfile = Puppetfile(github_repository, 'env', sha='shasha') assert puppetfile.git_modules == [] with pytest.raises(ModuleNotFoundException): puppetfile.update_git_module('apache', 'updatebranch')
def test_it_update_a_git_module_reference_and_reference_type(): github_repository = MagicMock() content = github_repository.get_file_contents() content.decoded_content.decode.return_value = ('') puppetfile = Puppetfile(github_repository, 'env', sha='shasha', git_modules=[deepcopy(GIT_MODULE_APACHE)]) assert puppetfile.git_modules[0].reference == 'ed19f' puppetfile.update_git_module('apache', 'master', reference_type='branch') assert puppetfile.git_modules[0].reference == 'master' assert puppetfile.git_modules[0].reference_type == 'branch'
def test_it_update_a_git_module_in_the_puppetfile(): github_repository = MagicMock() content = github_repository.get_file_contents() content.decoded_content.decode.return_value = ('') puppetfile = Puppetfile(github_repository, 'env', sha='shasha', git_modules=[deepcopy(GIT_MODULE_APACHE)]) assert puppetfile.git_modules[0].reference == 'ed19f' puppetfile.update_git_module('apache', 'a76f6fb') assert puppetfile.git_modules[0].reference == 'a76f6fb' github_repository.update_file.assert_called_once_with( "Puppetfile", "Puppetfile - Update git module apache from ed19f to a76f6fb", ("mod 'apache',\n" " :git => 'https://url/git/apache',\n" " :ref => 'a76f6fb'\n"), "shasha")