def test_create_benefits(self, a_client, a_client_user, a_benefit_rule):
        self.login(a_client, a_client_user.email, a_client_user.password)

        data = json.loads(a_benefit_rule.to_json())
        del data['_id']
        del data['original']
        del data['redeemed_by']
        response = self.post(a_client, 'api/v1/rules/', data)

        assert_201(response)
    def test_post_rule_should_create_one(self, a_client, a_client_user,
                                         a_consequence_data, a_condition_data):
        response = self.create_rule(
            a_client, a_client_user, {
                'consequence': a_consequence_data,
                'conditions': [a_condition_data],
                'name': 'a rule'
            })
        assert_201(response)

        assert Rule.objects.count() == 1
Exemple #3
0
    def test_create_user_rating(self, a_client, a_client_user, a_user_rating,
                                an_order):
        self.login(a_client, a_client_user.email, a_client_user.password)

        response = self.post(a_client, 'api/v1/user_ratings/', {
            'user': str(a_user_rating.user.id),
            'rating': 5,
            'order': an_order.id
        })

        assert_201(response)

        assert UserRating.objects.count() == 2
    def test_create_rule_should_return_newly_created(self, a_client,
                                                     a_client_user,
                                                     a_condition_data,
                                                     a_consequence_data):
        response = self.create_rule(
            a_client, a_client_user, {
                'conditions': [a_condition_data],
                'consequence': a_consequence_data,
                'name': 'a rule'
            })

        assert_201(response)

        rule = json.loads(response.data)

        assert rule
Exemple #5
0
    def test_create_favor_order_cycle(self, a_client, a_client_user_factory,
                                      another_customer_user,
                                      an_ordered_product):
        order_gp = 5
        a_client_user = a_client_user_factory(order_gp)

        self.login(a_client, a_client_user.email, a_client_user.password)
        response = self.post(
            a_client, 'api/v1/orders/', {
                'name':
                'new order',
                'order_type':
                Order.FAVOR_TYPE,
                'ordered_products':
                [{
                    'quantity': an_ordered_product.quantity,
                    'product': str(an_ordered_product.product.id)
                }],
                'payment_method':
                'GPPM',
                'gratitude_points':
                order_gp
            })

        assert_201(response)

        order = json.loads(response.data)

        response = self.patch(a_client,
                              'api/v1/orders/{}'.format(str(order['id'])),
                              {'delivery': another_customer_user.id})

        assert_200(response)

        assert User.objects.get(
            id=a_client_user.id).gratitude_points == order_gp

        response = self.patch(a_client,
                              'api/v1/orders/{}'.format(str(order['id'])),
                              {'status': Order.DELIVERED_STATUS})

        assert_200(response)

        assert User.objects.get(id=a_client_user.id).gratitude_points == 0
        assert User.objects.get(
            id=another_customer_user.id).gratitude_points == 10 + order_gp
    def test_create_and_get_rule(self, a_client, a_client_user,
                                 a_condition_data, a_consequence_data):
        create_response = self.create_rule(
            a_client, a_client_user, {
                'conditions': [a_condition_data],
                'consequence': a_consequence_data,
                'name': 'a rule'
            })

        assert_201(create_response)

        rule = json.loads(create_response.data)

        get_response = self.get_rule(a_client, a_client_user,
                                     Rule.objects.get(id=rule["id"]))

        assert_200(get_response)

        rule_returned = json.loads(get_response.data)

        assert rule_returned['id'] == rule['id']
 def test_user_should_be_able_to_create_chat(self, a_client, a_client_user):
     response = self.create_chat(a_client, a_client_user,
                                 str(a_client_user.id), "b", "c")
     assert_201(response)
 def test_chats_endpoint_exists(self, a_client, a_client_user):
     response = self.create_chat(a_client, a_client_user,
                                 str(a_client_user.id), "b", "c")
     assert_201(response)
Exemple #9
0
 def test_create_should_return_created_http_code(self, a_client,
                                                 a_client_user,
                                                 an_ordered_product):
     response = self.create_order("name", a_client, Order.NORMAL_TYPE,
                                  a_client_user, an_ordered_product)
     assert_201(response)
Exemple #10
0
 def test_user_should_be_able_to_create_order(self, a_client, a_client_user,
                                              an_ordered_product):
     response = self.create_order("name", a_client, Order.NORMAL_TYPE,
                                  a_client_user, an_ordered_product)
     assert_201(response)