Exemplo n.º 1
0
    def test_add_two_of_a_product(self):
        cart = ShoppingCart()
        product = Product('shoes', 'S', 'blue')

        cart.add_product(product, quantity=2)

        self.assertDictEqual({'SHOES-S-BLUE': {'quantity': 2}}, cart.products)
Exemplo n.º 2
0
    def test_remove_too_many_products(self):
        cart = ShoppingCart()
        product = Product('shoes', 'S', 'blue')

        cart.add_product(product)
        cart.remove_product(product, quantity=2)

        self.assertDictEqual({}, cart.products)
Exemplo n.º 3
0
    def test_add_and_remove_product(self):
        cart = ShoppingCart()  # <2>
        product = Product('shoes', 'S', 'blue')  # <3>

        cart.add_product(product)  # <4>
        cart.remove_product(product)  # <5>

        self.assertDictEqual({}, cart.products)  # <6>
Exemplo n.º 4
0
    def test_add_and_remove_product(self):
        cart = ShoppingCart()
        product = Product('shoes', 'S', 'blue')

        cart.add_product(product)
        cart.remove_product(product)

        self.assertDictEqual({}, cart.products)
Exemplo n.º 5
0
    def test_add_two_products(self):
        cart = ShoppingCart()
        product1 = Product('shoes', 'S', 'blue')
        product2 = Product('tshirt', 'M', 'black')

        cart.add_product(product1)
        cart.add_product(product2)

        expected_cart_value = {'SHOES-S-BLUE':{'quantity': 1}, 'TSHIRT-M-BLACK':{'quantity':1}}
        self.assertDictEqual(expected_cart_value, cart.products)
Exemplo n.º 6
0
    def test_add_and_remove_product(self):
        """
        We can consider this an integration test as it tests a chain of functional units
        """
        cart = ShoppingCart()
        product = Product('Cap', 'M', 'Orange')

        # these are two distinct actions
        cart.add_product(product)
        cart.remove_product(product)

        self.assertDictEqual({}, cart.products)
Exemplo n.º 7
0
    def test_add_two_different_products(self):
        cart = ShoppingCart()
        product_one = Product('shoes', 'S', 'blue')
        product_two = Product('shirt', 'M', 'gray')

        cart.add_product(product_one)
        cart.add_product(product_two)

        self.assertDictEqual(
            {
                'SHOES-S-BLUE': {
                    'quantity': 1
                },
                'SHIRT-M-GRAY': {
                    'quantity': 1
                }
            }, cart.products)
Exemplo n.º 8
0
 def test_remove_product_from_empty_cart(self):
     cart = ShoppingCart()
     product1 = Product('shoes', 'S', 'blue')
     cart.remove_product(product1)
     
     self.assertDictEqual({}, cart.products)
Exemplo n.º 9
0
 def new_cart(self):
     return ShoppingCart()
Exemplo n.º 10
0
def test_add_remove(list_of_books):
    cart = ShoppingCart()
    for book in list_of_books:
        cart.add(book)
        cart.remove(book)
    assert cart.total == 0.00
Exemplo n.º 11
0
def test_add(list_of_books):
    cart = ShoppingCart()
    for book in list_of_books:
        cart.add(book)
    total = sum(book.price for book in list_of_books)
    assert cart.total == total
Exemplo n.º 12
0
def test_add_discount(example_book):
    cart = ShoppingCart()
    cart.add(example_book)
    cart.add_discount(COUPONS["10OFF"])
    assert cart.total == 9.00
Exemplo n.º 13
0
 def test_cart_initially_empty(self):
     cart = ShoppingCart()
     self.assertDictEqual({}, cart.products)
Exemplo n.º 14
0
def test_add(example_book):
    cart = ShoppingCart()
    cart.add(example_book)
    assert cart.total == 10.00
Exemplo n.º 15
0
def test_add_remove(example_book):
    cart = ShoppingCart()
    cart.add(example_book)
    cart.remove(example_book)
    assert cart.total == 0.00
Exemplo n.º 16
0
engine = create_engine('sqlite:///user.db', echo=True)
from sqlalchemy.sql import text

app = Flask(__name__)

photos = UploadSet('photos', IMAGES)

app.config.from_object(
    'config'
)  # link config.py to this file(with all databse file paths, image upload paths)

configure_uploads(app, photos)

db = SQLAlchemy(app)
bootstrap = Bootstrap(app)
em_cart = ShoppingCart()
em_cart.total = 0


@app.route('/')
def home():
    items = Retailer.query.all()
    w_items = Wholeseller.query.all()
    govt = Government.query.all()
    retailer_list = ['kiran', 'raju', 'mani', 'jayanthi', 'naresh']
    best_retailer = random.choice(retailer_list)
    connection = engine.connect()
    s = text("SELECT SUM(price) FROM Retailer WHERE region=:r")
    total_revenue = 450
    return render_template('pages/index.html',
                           items=items,
Exemplo n.º 17
0
        MAIL_SERVER='smtp.googlemail.com',
        MAIL_PORT=465,
        MAIL_USE_TLS=False,
        MAIL_USE_SSL=True,
        MAIL_USERNAME='******',
        MAIL_PASSWORD='******',

        # administrator list
        ADMINS=['*****@*****.**', '*****@*****.**']))
configure_uploads(app, photos)

db = SQLAlchemy(app)
bootstrap = Bootstrap(app)
mail = Mail(app)

em_cart = ShoppingCart()  # initializations
em_cart.total = 0
order_placed = False


@app.route('/')
def home():
    items = Retailer.query.all()
    w_items = Wholeseller.query.all()
    govt = Government.query.all()
    retailer_list = ['kiran', 'raju', 'mani', 'jayanthi', 'naresh']
    best_retailer = random.choice(retailer_list)
    total_revenue = 450
    return render_template('pages/index.html',
                           items=items,
                           govt=govt,