Пример #1
0
class TestOrderRoutes:
    def setup(self):
        self.graph = create_app(testing=True)
        self.client = self.graph.flask.test_client()
        recreate_all(self.graph)

        self.new_order = Order(id=new_object_id(), )

    def teardown(self):
        self.graph.postgres.dispose()

    def test_create_and_retrieve(self):
        with SessionContext(self.graph), transaction():
            self.new_order.create()

        uri = f"/api/v1/order/{self.new_order.id}"

        response = self.client.get(uri)

        assert_that(response.status_code, is_(equal_to(200)))
        assert_that(
            response.json,
            has_entries(id=str(self.new_order.id), ),
        )

    def test_delete(self):
        with SessionContext(self.graph), transaction():
            self.new_order.create()

        uri = f"/api/v1/order/{self.new_order.id}"

        response = self.client.delete(uri)
        assert_that(response.status_code, is_(equal_to(204)))
Пример #2
0
    def test_delete_order(self):
        new_order = Order().create()

        retreived_order = self.order_store.retrieve(new_order.id)
        assert_that(retreived_order, is_(equal_to(new_order)))

        new_order.delete()
        assert_that(
            calling(self.order_store.retrieve).with_args(identifier=new_order.id),
            raises(ModelNotFoundError),
        )
Пример #3
0
    def setup(self):
        self.graph = create_app(testing=True)
        self.client = self.graph.flask.test_client()
        recreate_all(self.graph)

        with SessionContext(self.graph), transaction():
            self.new_order = Order().create()

            self.new_pizza = Pizza(
                id=new_object_id(),
                order_id=self.new_order.id,
                pizza_size=PizzaSize.SMALL.name,
                pizza_type=PizzaType.HANDTOSSED.name,
            ).create()

        self.first_topping = Topping(
            id=new_object_id(),
            pizza_id=self.new_pizza.id,
            topping_type=ToppingType.ONIONS,
        )

        self.second_topping = Topping(
            id=new_object_id(),
            pizza_id=self.new_pizza.id,
            topping_type=ToppingType.CHICKEN,
        )
Пример #4
0
    def test_create(self):
        new_order = Order()

        with transaction():
            self.order_store.create(new_order)

        retreived_order = self.order_store.retrieve(new_order.id)
        assert_that(retreived_order, is_(equal_to(new_order)))
Пример #5
0
    def setup(self):
        self.graph = create_app(testing=True)
        self.client = self.graph.flask.test_client()
        recreate_all(self.graph)
        with SessionContext(self.graph), transaction():
            self.new_order = Order().create()

        self.customer_event = CustomerStartedOrder(id=new_object_id(),
                                                   order_id=self.new_order.id)
    def test_create_customer_started_order(self):
        new_order = Order()

        with transaction():
            new_order = self.order_store.create(new_order)
            customer_event = self.customer_event_store.create(CustomerStartedOrder(order_id=new_order.id))

        retreived_customer_event = self.customer_event_store.retrieve(customer_event.id)
        assert_that(retreived_customer_event, is_(equal_to(customer_event)))
    def test_delete_order(self):
        new_order = Order().create()
        customer_started_order = self.customer_event_store.create(CustomerStartedOrder(order_id=new_order.id))
        retreived_event = self.customer_event_store.retrieve(customer_started_order.id)
        assert_that(retreived_event, is_(equal_to(customer_started_order)))

        customer_started_order.delete()
        assert_that(
            calling(self.customer_event_store.retrieve).with_args(identifier=customer_started_order.id),
            raises(ModelNotFoundError),
        )
    def test_create_customer_added_topping(self):
        with transaction():
            new_order = self.order_store.create(Order())
            customer_started_order = self.customer_event_store.create(CustomerStartedOrder(order_id=new_order.id))
            customer_added_topping = self.customer_event_store.create(
                CustomerAddedTopping(order_id=new_order.id, topping_type=ToppingType.CHICKEN,
                                     parent_id=customer_started_order.id
                                     ))

        retreived_customer_event = self.customer_event_store.retrieve(customer_added_topping.id)
        assert_that(retreived_customer_event, is_(equal_to(customer_added_topping)))
Пример #9
0
    def setup(self):
        self.graph = create_app(testing=True)
        self.pizza_store = self.graph.pizza_store

        self.pizza_type = PizzaType.HANDTOSSED.name
        self.pizza_size = PizzaSize.SMALL.name

        self.context = SessionContext(self.graph)
        self.context.recreate_all()
        self.context.open()

        self.new_order = Order().create()
Пример #10
0
    def setup(self):
        self.graph = create_app(testing=True)
        self.client = self.graph.flask.test_client()
        recreate_all(self.graph)

        self.new_order = Order(id=new_object_id(), )