def test_it_cannot_add_an_existing_module():
     github_repository = MagicMock()
     content = github_repository.get_file_contents()
     content.decoded_content.decode.return_value = ('')
     forge_module_apache = ForgeModule('puppetlabs/apache')
     puppetfile = Puppetfile(github_repository,
                             'env',
                             sha='shasha',
                             forge_modules=[forge_module_apache])
     with pytest.raises(ModuleAlreadyPresentException):
         puppetfile.add_forge_module('puppetlabs/apache')
 def test_it_add_a_module_to_the_puppetfile():
     github_repository = MagicMock()
     content = github_repository.get_file_contents()
     content.decoded_content.decode.return_value = ('')
     puppetfile = Puppetfile(github_repository,
                             'env',
                             sha='shasha',
                             forge_modules=[FORGE_MODULE_NGINX])
     assert puppetfile.forge_modules == [FORGE_MODULE_NGINX]
     puppetfile.add_forge_module('puppetlabs/apache', '0.1.10')
     forge_module_apache = ForgeModule('puppetlabs/apache', '0.1.10')
     assert forge_module_apache in puppetfile.forge_modules
     github_repository.update_file.assert_called_once_with(
         "Puppetfile", "Puppetfile - Add forge module puppetlabs/apache",
         f"{str(FORGE_MODULE_NGINX)}mod 'puppetlabs/apache', '0.1.10'\n",
         "shasha")