Exemplo n.º 1
0
    def remove_account(self, account_name: str) -> bool:
        """
        Remove account from whitelist.
        :param account_name: github login
        :return:
        """

        account_existed = False

        # Delete from Postgres
        if DBWhitelist.get_account(account_name) is not None:
            DBWhitelist.remove_account(account_name)
            logger.info(
                f"Account: {account_name} removed from postgres whitelist!")
            account_existed = True
        # Delete from redis
        if account_name in self.db:
            del self.db[account_name]
            # TODO: delete all artifacts from copr
            logger.info(
                f"Account: {account_name} removed from redis whitelist!")
            account_existed = True

        if account_existed:
            return True
        else:
            logger.info(f"Account: {account_name} does not exists!")
            return False
Exemplo n.º 2
0
def test_remove_account(multiple_whitelist_entries):
    assert Whitelist.get_account("Rayquaza").account_name == "Rayquaza"
    Whitelist.remove_account("Rayquaza")
    assert Whitelist.get_account("Rayquaza") is None