Exemple #1
0
    def test_find_by_name(self):
        """ Find by name """
        account = self._create_account()
        account.create()

        # Fetch it back by name
        same_account = Account.find_by_name(account.name)[0]
        self.assertEqual(same_account.id, account.id)
        self.assertEqual(same_account.name, account.name)
Exemple #2
0
def list_accounts():
    """ Returns all of the Accounts """
    app.logger.info("Request for Account list")
    accounts = []
    name = request.args.get("name")
    if name:
        accounts = Account.find_by_name(name)
    else:
        accounts = Account.all()

    results = [account.serialize() for account in accounts]
    return make_response(jsonify(results), status.HTTP_200_OK)