예제 #1
0
    def test_json_products_by_seller(self):
        product = db.session.query(Product).first()
        seller = db.session.query(Seller).first()

        with app.test_client() as client:
            response = client.get(f'/api/products/sellers/{seller.id}',
                                  follow_redirects=True)
        self.assertEqual(response.status_code, 200)
        assert product.name in str(response.data)
예제 #2
0
    def test_products_confirm_delete(self):
        product = db.session.query(Product).first()
        products_count = db.session.query(Product).count()

        with app.test_client() as client:
            response = client.delete(f'/products/{product.id}',
                                     follow_redirects=True)
        self.assertEqual(response.status_code, 200)
        assert products_count == (db.session.query(Product).count() + 1)
예제 #3
0
    def test_products_ask_delete(self):
        sentence = 'supprimer ce produit '
        product = db.session.query(Product).first()

        with app.test_client() as client:
            response = client.get(f'/products/delete/{product.id}',
                                  follow_redirects=True)
        self.assertEqual(response.status_code, 200)
        assert sentence in str(response.data)
예제 #4
0
    def test_products_show(self):

        product = db.session.query(Product).first()

        with app.test_client() as client:
            response = client.get(f'/products/{product.id}',
                                  content_type='html/text')
        self.assertEqual(response.status_code, 200)
        assert product.name in str(response.data)
예제 #5
0
    def test_customers_show(self):

        customer = db.session.query(Customer).first()

        with app.test_client() as client:
            response = client.get(f'/customers/{customer.id}',
                                  content_type='html/text')
        self.assertEqual(response.status_code, 200)
        assert 'Clients' in str(response.data)
        assert str(customer.id) in str(response.data)
예제 #6
0
    def test_orders_show(self):

        order = db.session.query(Order).first()

        with app.test_client() as client:
            response = client.get(f'/orders/{order.id}',
                                  content_type='html/text')
        self.assertEqual(response.status_code, 200)
        assert 'Commande' in str(response.data)
        assert str(order.id) in str(response.data)
예제 #7
0
    def test_products_create(self):
        name = 'new_product'
        seller = db.session.query(Seller).first()

        with app.test_client() as client:
            response = client.post(f'/products/new',
                                   data=dict(name=name,
                                             description='description',
                                             price=0.65,
                                             seller_id=seller.id,
                                             category='ARTICLE'),
                                   follow_redirects=True)
        self.assertEqual(response.status_code, 200)
예제 #8
0
    def test_products_edit(self):

        product = db.session.query(Product).first()
        product.name = 'updated_product'

        with app.test_client() as client:
            response = client.post(f'/products/update/{product.id}',
                                   data=dict(name=product.name,
                                             description=product.description,
                                             price=product.price,
                                             seller_id=product.seller_id,
                                             category=product.category),
                                   follow_redirects=True)
        self.assertEqual(response.status_code, 200)
예제 #9
0
 def test_customers_index(self):
     with app.test_client() as client:
         response = client.get('/customers', content_type='html/text')
     self.assertEqual(response.status_code, 200)
     assert 'Clients' in str(response.data)
예제 #10
0
 def test_products_index(self):
     with app.test_client() as client:
         response = client.get('/products', content_type='html/text')
     self.assertEqual(response.status_code, 200)
     assert 'les produits' in str(response.data)
예제 #11
0
 def test_index(self):
     with app.test_client() as client:
         response = client.get('/login', content_type='html/text')
     self.assertEqual(response.status_code, 200)