def test_get_customer_not_found(get_customer, web_client):
    get_customer.side_effect = CustomerNotFound()

    response = web_client.get('/customers/000000')

    assert response.is_json
    assert response.status_code == 404
    assert response.get_json() == dict(message='Customer not found')
Example #2
0
    def fetch_by_id(self, id):
        # print(type(id))
        # print(self.customers)
        if id not in self.customers:
            # print("hi")
            raise CustomerNotFound()

        return self.customers[id]
 def fetch_by_id(self, customer_id):
     try:
         return self.session \
             .query(Customer) \
             .filter(Customer.customer_id == customer_id) \
             .one()
     except NoResultFound:
         raise CustomerNotFound()
 def update_customer(self, surname, customer_id):
     try:
         self.session \
             .query(Customer) \
             .filter(Customer.customer_id == customer_id) \
             .update({"surname": surname})
         self.session.commit()
     except NoResultFound:
         raise CustomerNotFound()
Example #5
0
    def fetch_by_id(self, customer_id):
        doc_ref = self.customer_repo.document(customer_id)
        doc = doc_ref.get()
        logging.info("document: {}".format(doc))
        logging.info(u'Document data: {}'.format(doc.to_dict()))

        customer_json = doc.to_dict()
        if customer_json is not None:
            return Customer(customer_id=customer_json["customer_id"],
                            first_name=customer_json["firstName"],
                            surname=customer_json["surname"])
        else:
            raise CustomerNotFound()
    def fetch_by_id(self, id):
        if id not in self.customers:
            raise CustomerNotFound()

        return self.customers[id]