def test_insert_repo_subroutes_before_existing_repo_basepath( self, m_get_apt_auth_file, tmpdir): """Insert new repo_url before first matching url base path.""" auth_file = tmpdir.join("auth.conf").strpath util.write_file( auth_file, dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass """), ) m_get_apt_auth_file.return_value = auth_file add_apt_auth_conf_entry( login="******", password="******", repo_url="http://fakerepo/subroute", ) content_template = dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/subroute/ login new password newpass{} machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass """) expected_content = content_template.format(APT_AUTH_COMMENT) assert expected_content == util.load_file(auth_file)
def test_insert_repo_subroutes_before_existing_repo_basepath( self, m_get_apt_auth_file, tmpdir): """Insert new repo_url before first matching url base path.""" auth_file = tmpdir.join('auth.conf').strpath util.write_file( auth_file, dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass """)) m_get_apt_auth_file.return_value = auth_file add_apt_auth_conf_entry(login='******', password='******', repo_url='http://fakerepo/subroute') expected_content = dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/subroute/ login new password newpass%s machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass\ """ % APT_AUTH_COMMENT) assert expected_content == util.load_file(auth_file)
def test_replaces_old_credentials_with_new(self, m_get_apt_auth_file, tmpdir): """Replace old credentials for this repo_url on the same line.""" auth_file = tmpdir.join("auth.conf").strpath util.write_file( auth_file, dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass """), ) m_get_apt_auth_file.return_value = auth_file add_apt_auth_conf_entry(login="******", password="******", repo_url="http://fakerepo/") content_template = dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login newlogin password newpass{} machine fakerepo2/ login other password otherpass """) expected_content = content_template.format(APT_AUTH_COMMENT) assert expected_content == util.load_file(auth_file)
def test_replaces_old_credentials_with_new( self, m_get_apt_auth_file, tmpdir): """Replace old credentials for this repo_url on the same line.""" auth_file = tmpdir.join('auth.conf').strpath util.write_file(auth_file, dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login old password oldpassword machine fakerepo2/ login other password otherpass """)) m_get_apt_auth_file.return_value = auth_file add_apt_auth_conf_entry( login='******', password='******', repo_url='http://fakerepo/') expected_content = dedent("""\ machine fakerepo1/ login me password password1 machine fakerepo/ login newlogin password newpass%s machine fakerepo2/ login other password otherpass """ % APT_AUTH_COMMENT) assert expected_content == util.load_file(auth_file)