def test_deserialize_an_account(self): """ Deserialize an account """ address = self._create_address() account = self._create_account(addresses=[address]) serial_account = account.serialize() new_account = Account() new_account.deserialize(serial_account) self.assertEqual(new_account.id, account.id) self.assertEqual(new_account.name, account.name) self.assertEqual(new_account.email, account.email) self.assertEqual(new_account.phone_number, account.phone_number) self.assertEqual(new_account.date_joined, account.date_joined)
def create_accounts(): """ Creates an Account This endpoint will create an Account based the data in the body that is posted """ app.logger.info("Request to create an Account") check_content_type("application/json") account = Account() account.deserialize(request.get_json()) account.create() message = account.serialize() location_url = url_for("get_accounts", account_id=account.id, _external=True) return make_response(jsonify(message), status.HTTP_201_CREATED, {"Location": location_url})