示例#1
0
    def test_bidding_home(self):

        category = MarketCategory.objects.all()[0]
        subcategory = MarketSubCategory.objects.all()[0]

        now = datetime.datetime.now()
        now_plus_10 = now + datetime.timedelta(seconds=5)

        auction = AuctionSession(shop=self.shop,
                                 title="Auction Session Nr 4",
                                 description="-- no desc --",
                                 start=now,
                                 end=now_plus_10)
        auction.save()

        lot = Lot(shop=self.shop,
                  title="Coin From USA 1905 (PCGS 50)",
                  description="rare coin",
                  category=category,
                  date_time=now,
                  weight="5",
                  session=auction,
                  starting_bid=decimal.Decimal("100.00"),
                  reserve=decimal.Decimal("300.00"))
        lot.save()

        item = Item(shop=self.shop,
                    title="Item",
                    description="an item",
                    price="10.0",
                    category=category,
                    subcategory=subcategory,
                    qty=2,
                    weight="2.0")
        item.save()

        response = self.client.post(reverse("bidding_home"),
                                    {'email': "*****@*****.**"},
                                    HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 302)

        #            param = {
        #             'about': about,
        #             'home':
        #                {
        #                 'title': home.title,
        #                 'body': home.body,
        #                 'image': home.image
        #                 },
        #             'last_post': last_post,
        #             'mailing_list': block_mailing_list,
        #             'new_items': new_items,
        #             'page_title': 'Home',
        #             'page_description': striptags(home.body),
        #             'sessions': new_sessions,
        #            }

        response = self.client.get(reverse("bidding_home"),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)
    def testShippingCharge(self):
        item = Item(
            shop=self.shop,
            title="item",
            description="an item",
            price="10.0",
            category=self.category,
            subcategory=self.subcategory,
            qty=5,
            weight="2.0",
        )
        item.save()
        # add an item to the cart
        self.cart.add(item, item.price, qty=3)

        # set the shipping address
        shippingdata = ShippingData(
            street_address="Abey Road", city="Great Beach", state="MI", zip="11001", country="US"
        )
        shippingdata.save()
        self.cart.shippingdata = shippingdata

        sw1 = ShippingWeight(
            shop=self.shop, name="Shipping by Weight", price="3.00", from_weight="0.0", to_weight="5.0"
        )
        sw1.save()
        sw2 = ShippingWeight(
            shop=self.shop, name="Shipping by Weight", price="5.00", from_weight="5.0", to_weight="10.0"
        )
        sw2.save()
        self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("5.0"))
        sw1.delete()
        sw2.delete()

        si1 = ShippingItem(shop=self.shop, name="Shipping by Item", price="9.00", from_item=0, to_item=3)
        si1.save()
        si2 = ShippingItem(shop=self.shop, name="Shipping by Item", price="19.00", from_item=3, to_item=5)
        si2.save()
        si3 = ShippingItem(shop=self.shop, name="Shipping by Item", price="29.00", from_item=5, to_item=15)
        si3.save()

        self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("9.0"))
        si1.delete()
        si2.delete()
        si3.delete()

        pw1 = ShippingPrice(shop=self.shop, name="Shipping by Price", price="5.00", from_price="0.0", to_price="20.0")
        pw1.save()
        pw2 = ShippingPrice(shop=self.shop, name="Shipping by Price", price="9.00", from_price="20.0", to_price="40.0")
        pw2.save()
        self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("9.0"))
        pw1.delete()
        pw2.delete()
    def test_bidding_home(self):
        
        category = MarketCategory.objects.all()[0]
        subcategory = MarketSubCategory.objects.all()[0]

        now = datetime.datetime.now()
        now_plus_10 = now + datetime.timedelta(seconds=5)
        
        auction = AuctionSession(shop=self.shop, title="Auction Session Nr 4", 
                                 description="-- no desc --", 
                                 start=now, 
                                 end=now_plus_10)
        auction.save()
        
        lot = Lot(shop=self.shop,
                  title="Coin From USA 1905 (PCGS 50)",
                  description="rare coin",
                  category=category,
                  date_time=now,
                  weight="5",
                  session=auction, 
                  starting_bid=decimal.Decimal("100.00"), 
                  reserve=decimal.Decimal("300.00"))
        lot.save()
        
        item = Item(shop=self.shop, title="Item", description="an item", 
                    price="10.0", 
                    category=category, 
                    subcategory=subcategory, 
                    qty=2, weight="2.0")
        item.save() 
        
        response = self.client.post(reverse("bidding_home"), {'email': "*****@*****.**"}, HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 302)
            
#            param = {
#             'about': about,
#             'home': 
#                {
#                 'title': home.title, 
#                 'body': home.body, 
#                 'image': home.image
#                 },
#             'last_post': last_post,
#             'mailing_list': block_mailing_list,
#             'new_items': new_items,
#             'page_title': 'Home',
#             'page_description': striptags(home.body),
#             'sessions': new_sessions,
#            }
            
        response = self.client.get(reverse("bidding_home"), HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)
示例#4
0
 def testItemCreate(self):
     import logging
     from inventory.models import Product
     products_count = Product.objects.count()
     item = Item(shop=self.shop, title="item", description="an item", 
                 price="10.0", category=self.category, subcategory=self.subcategory, 
                 qty=1, weight="2.0")
     item.save()
     
     #check Product was created
     self.assertEqual(products_count + 1, Product.objects.count())
     #check Product was deleted
     item.delete()
     self.assertEqual(products_count, Product.objects.count())
 def testItemCreate(self):
     import logging
     from inventory.models import Product
     products_count = Product.objects.count()
     item = Item(shop=self.shop, title="item", description="an item", 
                 price="10.0", category=self.category, subcategory=self.subcategory, 
                 qty=1, weight="2.0")
     item.save()
     
     #check Product was created
     self.assertEqual(products_count + 1, Product.objects.count())
     #check Product was deleted
     item.delete()
     self.assertEqual(products_count, Product.objects.count())
    def testCartMethods(self):
        item = Item(
            shop=self.shop,
            title="item",
            description="an item",
            price="10.0",
            category=self.category,
            subcategory=self.subcategory,
            qty=5,
            weight="2.0",
        )
        item.save()

        shippingdata = ShippingData(
            street_address="Calle 8 n 182", city="La Plata", state="Buenos Aires", zip="1900", country="AR"
        )
        shippingdata.save()

        self.cart.shippingdata = shippingdata

        qty = item.qty
        # add an item to cart
        qty_to_buy = 2
        self.cart.add(item, item.price, qty=qty_to_buy)

        # check that qty item NOT decrease
        self.assertEqual(qty, item.qty)

        # check that item is in cart
        cart_item = self.cart.cartitem_set.all()[0]
        self.assertEqual(item, cart_item.product)

        # check cart methods
        self.assertEqual(self.cart.total_items(), qty_to_buy)
        self.assertEqual(self.cart.total_weight(), decimal.Decimal("4.0"))
        self.assertEqual(self.cart.total(), decimal.Decimal("20.0"))
        self.assertEqual(self.cart.total_with_taxes(), decimal.Decimal("20.0"))

        # clean the cart
        self.cart.clean()

        # recheck cart methods
        self.assertEqual(self.cart.total_items(), 0)
        self.assertEqual(self.cart.total_weight(), decimal.Decimal("0.0"))
        self.assertEqual(self.cart.total(), decimal.Decimal("0.0"))
        self.assertEqual(self.cart.total_with_taxes(), decimal.Decimal("0.0"))
示例#7
0
 def testShippingCharge(self):
     item = Item(shop=self.shop, 
             title="item",
             description="an item", 
             price="10.0", 
             category=self.category, 
             subcategory=self.subcategory, 
             qty=5, 
             weight="2.0")
     item.save()
     #add an item to the cart
     self.cart.add(item, item.price, qty=3)
     
     #set the shipping address        
     shippingdata = ShippingData(street_address="Abey Road", city="Great Beach", state="MI", zip="11001", country="US")
     shippingdata.save()
     self.cart.shippingdata = shippingdata
     
     sw1 = ShippingWeight(shop=self.shop, name="Shipping by Weight", price="3.00", from_weight="0.0", to_weight="5.0")
     sw1.save()
     sw2 = ShippingWeight(shop=self.shop, name="Shipping by Weight", price="5.00", from_weight="5.0", to_weight="10.0")
     sw2.save()
     self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("5.0"))
     sw1.delete()
     sw2.delete()
     
     si1 = ShippingItem(shop=self.shop, name="Shipping by Item", price="9.00", from_item=0, to_item=3)
     si1.save()
     si2 = ShippingItem(shop=self.shop, name="Shipping by Item", price="19.00", from_item=3, to_item=5)
     si2.save()
     si3 = ShippingItem(shop=self.shop, name="Shipping by Item", price="29.00", from_item=5, to_item=15)
     si3.save()
     
     self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("9.0"))
     si1.delete()
     si2.delete()
     si3.delete()
     
     pw1 = ShippingPrice(shop=self.shop, name="Shipping by Price", price="5.00", from_price="0.0", to_price="20.0")
     pw1.save()
     pw2 = ShippingPrice(shop=self.shop, name="Shipping by Price", price="9.00", from_price="20.0", to_price="40.0")
     pw2.save()
     self.assertEquals(self.cart.shipping_charge(), decimal.Decimal("9.0"))
     pw1.delete()
     pw2.delete()
    def testTaxCalculation(self):
        item = Item(
            shop=self.shop,
            title="item",
            description="an item",
            price="10.0",
            category=self.category,
            subcategory=self.subcategory,
            qty=5,
            weight="2.0",
        )
        item.save()

        # load some taxes
        miami_tax = decimal.Decimal("2.5")
        tax_for_miami = TaxState(shop=self.shop, state="MI", tax=miami_tax)
        tax_for_miami.save()

        ny_tax = decimal.Decimal("1.5")
        tax_for_ny = TaxState(shop=self.shop, state="NY", tax=ny_tax)
        tax_for_ny.save()

        # add an item to the cart
        self.cart.add(item, item.price, qty=1)

        # set the shipping address
        shippingdata = ShippingData(
            street_address="Abey Road", city="Great Beach", state="MI", zip="11001", country="US"
        )
        shippingdata.save()
        self.cart.shippingdata = shippingdata

        # check that tax is correctly calculated
        self.assertEquals(self.cart.taxes(), miami_tax * decimal.Decimal(item.price) / decimal.Decimal("100.0"))
        self.assertNotEquals(self.cart.taxes(), ny_tax * decimal.Decimal(item.price) / decimal.Decimal("100.0"))

        # if shipping address is not MI or NY, no tax must be applied...
        shippingdata = ShippingData(
            street_address="Abey Road", city="Great Beach", state="IO", zip="11001", country="US"
        )
        shippingdata.save()
        self.cart.shippingdata = shippingdata

        self.assertEquals(self.cart.taxes(), decimal.Decimal("0.0"))
 def testCartClose(self):
     item = Item(shop=self.shop, 
             title="item",
             description="an item", 
             price="10.0", 
             category=self.category, 
             subcategory=self.subcategory, 
             qty=2, 
             weight="2.0")
     item.save()
     
     item2 = Item(shop=self.shop, 
             title="item",
             description="an item", 
             price="10.0", 
             category=self.category, 
             subcategory=self.subcategory, 
             qty=2, 
             weight="2.0")
     item2.save()
     
     shippingdata = ShippingData(street_address="Calle 8 n 182", city="La Plata", state="Buenos Aires", zip="1900", country="AR")
     shippingdata.save()
     
     #add the shipping data
     self.cart.shippingdata = shippingdata
     self.cart.save()
     
     #add 2 items
     self.cart.add(item, item.price, qty=1)
     self.cart.add(item2, item.price, qty=2)
     
     #close the cart
     sell = self.cart.close("manual")
     
     #check that the sell object has the default values setted... 
     self.assertEquals(self.cart.total_items(), 0)
     self.assertEquals(sell.closed, False)
     self.assertEquals(sell.sellitem_set.count(), 2)
     self.assertEquals(sell.payment.state_actual.state, "PE")
     self.assertEquals(sell.shipping.state_actual.state, "PE")
     
     
示例#10
0
    def testCartMethods(self):
        item = Item(shop=self.shop, 
                        title="item",
                        description="an item", 
                        price="10.0", 
                        category=self.category, 
                        subcategory=self.subcategory, 
                        qty=5, 
                        weight="2.0")
        item.save()
        
        
        shippingdata = ShippingData(street_address="Calle 8 n 182", city="La Plata", state="Buenos Aires", zip="1900", country="AR")
        shippingdata.save()

        self.cart.shippingdata = shippingdata
                
        qty = item.qty
        #add an item to cart
        qty_to_buy = 2
        self.cart.add(item, item.price, qty=qty_to_buy)
        
        #check that qty item NOT decrease
        self.assertEqual(qty, item.qty)
        
        #check that item is in cart
        cart_item = self.cart.cartitem_set.all()[0]
        self.assertEqual(item, cart_item.product)
        
        #check cart methods
        self.assertEqual(self.cart.total_items(), qty_to_buy)
        self.assertEqual(self.cart.total_weight() , decimal.Decimal("4.0"))
        self.assertEqual(self.cart.total(), decimal.Decimal("20.0"))
        self.assertEqual(self.cart.total_with_taxes(), decimal.Decimal("20.0"))
        
        #clean the cart
        self.cart.clean()
        
        #recheck cart methods
        self.assertEqual(self.cart.total_items(), 0)
        self.assertEqual(self.cart.total_weight() , decimal.Decimal("0.0"))
        self.assertEqual(self.cart.total(), decimal.Decimal("0.0"))
        self.assertEqual(self.cart.total_with_taxes(), decimal.Decimal("0.0"))
示例#11
0
    def testTaxCalculation(self):
        item = Item(shop=self.shop, 
                title="item",
                description="an item", 
                price="10.0", 
                category=self.category, 
                subcategory=self.subcategory, 
                qty=5, 
                weight="2.0")
        item.save()
        
        #load some taxes 
        miami_tax = decimal.Decimal("2.5")
        tax_for_miami = TaxState(shop=self.shop, state="MI", tax=miami_tax)
        tax_for_miami.save()
        
        ny_tax = decimal.Decimal("1.5")
        tax_for_ny = TaxState(shop=self.shop, state="NY", tax=ny_tax)
        tax_for_ny.save()
        
        #add an item to the cart
        self.cart.add(item, item.price, qty=1)
        
        #set the shipping address        
        shippingdata = ShippingData(street_address="Abey Road", city="Great Beach", state="MI", zip="11001", country="US")
        shippingdata.save()
        self.cart.shippingdata = shippingdata
      
        #check that tax is correctly calculated
        self.assertEquals(self.cart.taxes(), miami_tax * decimal.Decimal(item.price) / decimal.Decimal("100.0"))
        self.assertNotEquals(self.cart.taxes(), ny_tax * decimal.Decimal(item.price) / decimal.Decimal("100.0"))

        #if shipping address is not MI or NY, no tax must be applied...
        shippingdata = ShippingData(street_address="Abey Road", city="Great Beach", state="IO", zip="11001", country="US")
        shippingdata.save()
        self.cart.shippingdata = shippingdata

        self.assertEquals(self.cart.taxes(), decimal.Decimal("0.0") )        
示例#12
0
    def testSoldOut(self):
        # create a item
        item = Item(shop=self.shop,
                title="item",
                description="an item",
                price="10.0",
                category=self.category,
                subcategory=self.subcategory,
                qty=1,
                weight="2.0")
        item.save()
        
        # verify if the item is showing
        self.assertTrue(item.show)

        # add the item to cart
        self.cart.add(item, item.price, qty=1)
        self.cart.close('manual')

        # reload the item from db
        item = Item.objects.get(id=item.id)

        # verify if the item is showing and stock=0
        self.assertTrue(item.show)
        self.assertEqual(item.qty, 0)

        # change item sold_out_date and verify if the item is still showing
        past_date = datetime.datetime.now() - datetime.timedelta(days=13)
        item.sold_out_date = past_date
        item.update_show(True)
        self.assertTrue(item.show)

        # again, this time the item will not showing
        past_date = datetime.datetime.now() - datetime.timedelta(days=25)
        item.sold_out_date = past_date
        item.update_show(True)
        self.assertFalse(item.show)

        item.qty = 1
        item.save()
        self.assertTrue(item.show)

        item.qty = 0
        item.save()
        self.assertTrue(item.show)

        #
        past_date = datetime.datetime.now() - datetime.timedelta(days=25)
        item.sold_out_date = past_date
        item.update_show(True)
        self.assertFalse(item.show)
示例#13
0
    def test_urls_access(self):

        context = decimal.Context(prec=20, rounding=decimal.ROUND_HALF_DOWN)
        decimal.setcontext(context)

        shop = Shop.objects.all()[0]
        category = MarketCategory.objects.all()[0]
        HTTP_HOST = shop.default_dns

        now = datetime.datetime.now()
        tomorrow = now + datetime.timedelta(days=1)
        auction = AuctionSession(shop=shop,
                                 title="Auction Session Nr 0",
                                 description="-- no desc --",
                                 start=now,
                                 end=tomorrow)
        auction.save()

        lot = Lot(shop=shop,
                  title="Coin From Egypt 1905 (PCGS 60)",
                  description="rare coin",
                  category=category,
                  date_time=now,
                  weight="5",
                  session=auction,
                  starting_bid=decimal.Decimal("10.00"),
                  reserve=decimal.Decimal("0.00"))
        lot.save()

        item = Item(shop=shop,
                    title="Coin From Rusia 1917 (PCGS 60)",
                    description="rare coin",
                    category=category,
                    date_time=now,
                    weight="5",
                    qty="10",
                    price=decimal.Decimal("150"))
        item.save()

        user = shop.admin
        #        response = self.client.get(reverse("bidding_view_lot", args=[lot.id]), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to view lot")
        #
        success = self.client.login(username=user.username, password="******")
        self.assertEqual(success, True, "Login failed")

        ############# CUSTOMERS ################
        response = self.client.get(reverse("home_admin"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach home_admin")

        response = self.client.get(reverse("customers"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers")

        response = self.client.get(reverse("customers_overview"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_overview")

        response = self.client.get(reverse("customers_profiles"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_profiles")

        response = self.client.get(reverse("customers_sold_items"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_sold_items")

        response = self.client.get(reverse("customers_payments"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_payments")

        response = self.client.get(reverse("customers_shipments"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_shipments")

        response = self.client.get(reverse("customers_wish_lists"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_wish_list")

        #        response = self.client.get(reverse("customers_send_notification"), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")

        response = self.client.get(reverse("customers_mailing_list"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach customers_mailing_list")

        response = self.client.get(reverse("customers_export_mailinglist"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(
            response.status_code, 200,
            "Failed when trying to reach customers_export_mailinglist")

        ######### WEBSTORE ############
        response = self.client.get(reverse("web_store"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store")

        response = self.client.get(reverse("web_store_overview"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_overview")

        response = self.client.get(reverse("web_store_marketing"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_marketing")

        response = self.client.get(reverse("web_store_shows"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_shows")

        #        response = self.client.get(reverse("web_store_theme"), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_theme")

        response = self.client.get(reverse("web_store_pages"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_pages")

        response = self.client.get(reverse("web_store_blogs"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_blogs")

        response = self.client.get(reverse("web_store_navigation"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach web_store_navigation")

        #        response = self.client.get(reverse("web_store_show_go"), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
        #
        #        response = self.client.get(reverse("web_store_show_not_go"), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
        #
        #        response = self.client.get(reverse("web_store_theme"), HTTP_HOST=HTTP_HOST)
        #        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")

        ######### INVENTORY ##########
        response = self.client.get(reverse("inventory"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory")

        response = self.client.get(reverse("inventory_overview"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_overview")

        response = self.client.get(reverse("inventory_items"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_items")

        response = self.client.get(reverse("inventory_items_import"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_items_import")

        response = self.client.get(reverse("inventory_lots"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_lots")

        response = self.client.get(reverse("inventory_auctions"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_auctions")

        response = self.client.get(reverse("inventory_categorize"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach inventory_categorize")

        ######## ACCOUNT #########
        response = self.client.get(reverse("account"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach account")

        response = self.client.get(reverse("account_profile"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach account_profile")

        response = self.client.get(reverse("account_password"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach account_password")

        response = self.client.get(reverse("add_profile_photo"),
                                   HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 302,
                         "Failed when trying to reach add_profile_photo")

        response = self.client.get(reverse("preferences"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200,
                         "Failed when trying to reach preferences")
示例#14
0
    def testCartClose(self):
        item = Item(
            shop=self.shop,
            title="item",
            description="an item",
            price="10.0",
            category=self.category,
            subcategory=self.subcategory,
            qty=1,
            weight="2.0",
        )
        item.save()

        item2 = Item(
            shop=self.shop,
            title="item",
            description="an item",
            price="10.0",
            category=self.category,
            subcategory=self.subcategory,
            qty=2,
            weight="2.0",
        )
        item2.save()

        stock_item = item.qty
        stock_item2 = item2.qty

        shippingdata = ShippingData(
            street_address="Calle 8 n 182", city="La Plata", state="Buenos Aires", zip="1900", country="AR"
        )
        shippingdata.save()

        # add the shipping data
        self.cart.shippingdata = shippingdata
        self.cart.save()

        # add 2 items
        self.cart.add(item, item.price, qty=1)
        self.cart.add(item2, item2.price, qty=2)

        item = Item.objects.get(id=item.id)
        self.cart2.add(item, item.price, qty=1)

        item = Item.objects.get(id=item.id)
        self.assertEqual(stock_item, item.qty)
        self.assertEqual(stock_item2, item2.qty)

        success = self.client.login(username="******", password="******")
        self.assertEqual(success, True, "login failed")
        HTTP_HOST = self.shop.default_dns
        response = self.client.get(reverse("myshopping_checkout_shipping"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200)
        shipping_data = {
            "first_name": "User",
            "last_name": "Buyer",
            "street_address": "Street 54",
            "city": "Washington",
            "state": "DC",
            "zip": "12345-4321",
            "country": "United States",
        }
        response = self.client.post(reverse("myshopping_checkout_shipping"), shipping_data, HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 302)

        # cart and cart2 is availables
        self.assertTrue(self.cart.is_available())
        self.assertTrue(self.cart2.is_available())

        # close the cart
        sell = self.cart.close("manual")

        self.assertTrue(self.cart.is_available())

        # cart2 is not available
        self.assertFalse(self.cart2.is_available())

        response = self.client.get(reverse("myshopping_checkout_confirm"), HTTP_HOST=HTTP_HOST, follow=True)
        self.assertRedirects(response, reverse("my_shopping"), status_code=302, host=HTTP_HOST)
        logging.info("\t%s" % response.redirect_chain)

        item = Item.objects.get(id=item.id)
        item2 = Item.objects.get(id=item2.id)

        self.assertEqual(stock_item - 1, item.qty)
        self.assertEqual(stock_item2 - 2, item2.qty)

        # check that the sell object has the default values setted...
        self.assertEquals(self.cart.total_items(), 0)
        self.assertEquals(sell.closed, False)
        self.assertEquals(sell.sellitem_set.count(), 2)
        self.assertEquals(sell.payment.state_actual.state, "PE")
        self.assertEquals(sell.shipping.state_actual.state, "PE")
示例#15
0
    def test_bidding_views(self):

        now = datetime.datetime.now()
        tomarrow = now + datetime.timedelta(days=1)
        category = MarketCategory.objects.all()[0]
        subcategory = MarketSubCategory.objects.all()[0]

        item = Item(shop=self.shop,
                    title="My Unique Item",
                    description="the description of my unique item",
                    price="10.0",
                    category=category,
                    subcategory=subcategory,
                    qty=2,
                    weight="2.0")
        item.save()

        auction = AuctionSession(shop=self.shop,
                                 title="Test Session",
                                 description="-- no desc --",
                                 start=now,
                                 end=tomarrow)
        auction.save()

        lot = Lot(shop=self.shop,
                  title="Coin From USA 1905 (PCGS 50)",
                  description="rare coin",
                  category=category,
                  date_time=now,
                  weight="5",
                  session=auction,
                  starting_bid=decimal.Decimal("100.00"),
                  reserve=decimal.Decimal("300.00"))
        lot.save()

        response = self.client.get(reverse("bidding_about_us"),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertContains(
            response,
            "Nam est mauris, pretium eu imperdiet ut, iaculis sit amet sapien",
            count=None,
            status_code=200,
            msg_prefix='')

        response = self.client.get(reverse("bidding_auctions_id",
                                           args=[auction.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['sessions']), 1)

        response = self.client.get(reverse("bidding_blog"),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(reverse("bidding_buy_now", args=[item.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 302)

        #bidding_search

        page = Page(shop=self.shop,
                    name_link="somewhere",
                    title="Page Title",
                    body="This is the page content")
        page.save()
        response = self.client.get(reverse("bidding_page",
                                           args=[page.name_link]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertContains(response,
                            "Page Title",
                            count=None,
                            status_code=200,
                            msg_prefix='')
        self.assertContains(response,
                            "This is the page content",
                            count=None,
                            status_code=200,
                            msg_prefix='')

        response = self.client.get(reverse("bidding_sitemap"),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        #self.assertContains(response, "Page Title", count=None, status_code=200, msg_prefix='')

        response = self.client.get(reverse("bidding_for_sale"),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(reverse("bidding_map",
                                           args=[self.shop.about.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(reverse("bidding_view_history_lot",
                                           args=[lot.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        response = self.client.post(reverse("bidding_view_history_lot",
                                            args=[lot.id]),
                                    {'amount': '10.00'},
                                    HTTP_HOST=self.HTTP_HOST)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(reverse("bidding_view_item",
                                           args=[item.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertContains(response,
                            "My Unique Item",
                            count=None,
                            status_code=200,
                            msg_prefix='')

        post = Post(shop=self.shop,
                    title="This is my first blog post",
                    body="some content here")
        post.save()

        self.assertEqual(post.views, 0)
        response = self.client.get(reverse("bidding_view_post",
                                           args=[post.id]),
                                   HTTP_HOST=self.HTTP_HOST)
        self.assertContains(response,
                            "This is my first blog post",
                            count=None,
                            status_code=200,
                            msg_prefix='')

        post = Post.objects.filter(id=post.id)[0]
        self.assertEqual(post.views, 1)
 def test_bidding_views(self):
     
     now = datetime.datetime.now()
     tomarrow = now + datetime.timedelta(days=1)
     category = MarketCategory.objects.all()[0]
     subcategory = MarketSubCategory.objects.all()[0]
     
     item = Item(shop=self.shop, title="My Unique Item", description="the description of my unique item", 
                 price="10.0", 
                 category=category, 
                 subcategory=subcategory, 
                 qty=2, weight="2.0")
     item.save() 
     
     auction = AuctionSession(shop=self.shop, title="Test Session", 
                              description="-- no desc --", 
                              start=now, 
                              end=tomarrow)
     auction.save()
     
     lot = Lot(shop=self.shop,
               title="Coin From USA 1905 (PCGS 50)",
               description="rare coin",
               category=category,
               date_time=now,
               weight="5",
               session=auction, 
               starting_bid=decimal.Decimal("100.00"), 
               reserve=decimal.Decimal("300.00"))
     lot.save()
     
     
     response = self.client.get(reverse("bidding_about_us"), HTTP_HOST=self.HTTP_HOST)
     self.assertContains(response, "Nam est mauris, pretium eu imperdiet ut, iaculis sit amet sapien", count=None, status_code=200, msg_prefix='')     
     
     response = self.client.get(reverse("bidding_auctions_id", args=[auction.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.context['sessions']), 1)
     
     response = self.client.get(reverse("bidding_blog"), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     
     response = self.client.get(reverse("bidding_buy_now", args=[item.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 302)
     
     #bidding_search
 
     page = Page(shop=self.shop, name_link="somewhere", title="Page Title", body="This is the page content")
     page.save()
     response = self.client.get(reverse("bidding_page", args=[page.name_link]), HTTP_HOST=self.HTTP_HOST)
     self.assertContains(response, "Page Title", count=None, status_code=200, msg_prefix='')
     self.assertContains(response, "This is the page content", count=None, status_code=200, msg_prefix='')
     
     response = self.client.get(reverse("bidding_sitemap"), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     
     #self.assertContains(response, "Page Title", count=None, status_code=200, msg_prefix='')
     
     response = self.client.get(reverse("bidding_for_sale"), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     
     response = self.client.get(reverse("bidding_map", args=[self.shop.about.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
         
     response = self.client.get(reverse("bidding_view_history_lot", args=[lot.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     
     response = self.client.post(reverse("bidding_view_history_lot", args=[lot.id]), {'amount': '10.00' },HTTP_HOST=self.HTTP_HOST)
     self.assertEqual(response.status_code, 200)
     
     response = self.client.get(reverse("bidding_view_item", args=[item.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertContains(response, "My Unique Item", count=None, status_code=200, msg_prefix='')
     
     post = Post(shop=self.shop, title="This is my first blog post", body="some content here")
     post.save()
     
     self.assertEqual(post.views, 0)
     response = self.client.get(reverse("bidding_view_post", args=[post.id]), HTTP_HOST=self.HTTP_HOST)
     self.assertContains(response, "This is my first blog post" , count=None, status_code=200, msg_prefix='')
 
     post = Post.objects.filter(id=post.id)[0]
     self.assertEqual(post.views, 1)
示例#17
0
    def testCartClose(self):
        item = Item(shop=self.shop, 
                title="item",
                description="an item", 
                price="10.0", 
                category=self.category, 
                subcategory=self.subcategory, 
                qty=1, 
                weight="2.0")
        item.save()
        
        item2 = Item(shop=self.shop, 
                title="item",
                description="an item", 
                price="10.0", 
                category=self.category, 
                subcategory=self.subcategory, 
                qty=2, 
                weight="2.0")
        item2.save()

        stock_item = item.qty
        stock_item2 = item2.qty
        
        shippingdata = ShippingData(street_address="Calle 8 n 182", city="La Plata", state="Buenos Aires", zip="1900", country="AR")
        shippingdata.save()
        
        #add the shipping data
        self.cart.shippingdata = shippingdata
        self.cart.save()
        
        #add 2 items
        self.cart.add(item, item.price, qty=1)
        self.cart.add(item2, item2.price, qty=2)
        
        item = Item.objects.get(id=item.id)
        self.cart2.add(item, item.price, qty=1)
        
        item = Item.objects.get(id=item.id)
        self.assertEqual(stock_item, item.qty)
        self.assertEqual(stock_item2, item2.qty)
        
        success = self.client.login(username='******', password='******')
        self.assertEqual(success, True, "login failed")
        HTTP_HOST = self.shop.default_dns
        response = self.client.get(reverse("myshopping_checkout_shipping"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200)
        shipping_data = { 
            'first_name': 'User',
            'last_name': 'Buyer',
            'street_address': 'Street 54',
            'city': 'Washington',
            'state': 'DC',
            'zip': '12345-4321',
            'country': 'United States',
        }
        response = self.client.post(reverse("myshopping_checkout_shipping"), shipping_data, HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 302)


        # cart and cart2 is availables
        self.assertTrue(self.cart.is_available())
        self.assertTrue(self.cart2.is_available())
        
        #close the cart
        sell = self.cart.close("manual")
        
        self.assertTrue(self.cart.is_available())

        # cart2 is not available
        self.assertFalse(self.cart2.is_available())
         
        response = self.client.get(reverse("myshopping_checkout_confirm"), HTTP_HOST=HTTP_HOST,  follow=True)
        self.assertRedirects(response, reverse('my_shopping'),  status_code=302, host=HTTP_HOST)
        logging.info('\t%s' % response.redirect_chain)

        item = Item.objects.get(id=item.id)
        item2 = Item.objects.get(id=item2.id)
        
        self.assertEqual(stock_item - 1, item.qty)
        self.assertEqual(stock_item2 - 2, item2.qty)
        
        #check that the sell object has the default values setted... 
        self.assertEquals(self.cart.total_items(), 0)
        self.assertEquals(sell.closed, False)
        self.assertEquals(sell.sellitem_set.count(), 2)
        self.assertEquals(sell.payment.state_actual.state, "PE")
        self.assertEquals(sell.shipping.state_actual.state, "PE")

        
        
        
    def test_urls_access(self):
        
        context = decimal.Context(prec=20, rounding=decimal.ROUND_HALF_DOWN)
        decimal.setcontext(context)
    
        shop = Shop.objects.all()[0]
        category = MarketCategory.objects.all()[0]
        HTTP_HOST = shop.default_dns
        
        now = datetime.datetime.now()
        tomorrow = now + datetime.timedelta(days=1)
        auction = AuctionSession(shop=shop, title="Auction Session Nr 0", description="-- no desc --", start=now, end=tomorrow)
        auction.save()
        
        lot = Lot(shop = shop,
                  title = "Coin From Egypt 1905 (PCGS 60)",
                  description = "rare coin",
                  category = category,
                  date_time = now,
                  weight = "5",
                  session=auction, 
                  starting_bid=decimal.Decimal("10.00"), 
                  reserve=decimal.Decimal("0.00"))
        lot.save()
        
        item = Item(shop = shop,
                  title = "Coin From Rusia 1917 (PCGS 60)",
                  description = "rare coin",
                  category = category,
                  date_time = now,
                  weight = "5",
                  qty = "10",
                  price = decimal.Decimal("150"))
        item.save()
        
        user = shop.admin
#        response = self.client.get(reverse("bidding_view_lot", args=[lot.id]), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to view lot")
#       
        success = self.client.login(username=user.username, password="******")
        self.assertEqual(success, True, "Login failed")
         
        ############# CUSTOMERS ################
        response = self.client.get(reverse("home_admin"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach home_admin")
        
        response = self.client.get(reverse("customers"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers")
        
        response = self.client.get(reverse("customers_overview"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_overview")
        
        response = self.client.get(reverse("customers_profiles"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_profiles")
        
        response = self.client.get(reverse("customers_sold_items"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_sold_items")
        
        response = self.client.get(reverse("customers_payments"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_payments")
        
        response = self.client.get(reverse("customers_shipments"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_shipments")
        
        response = self.client.get(reverse("customers_wish_lists"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_wish_list")
        
#        response = self.client.get(reverse("customers_send_notification"), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
        
        response = self.client.get(reverse("customers_mailing_list"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_mailing_list")
        
        response = self.client.get(reverse("customers_export_mailinglist"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach customers_export_mailinglist")
        
        ######### WEBSTORE ############
        response = self.client.get(reverse("web_store"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store")
        
        response = self.client.get(reverse("web_store_overview"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_overview")
        
        response = self.client.get(reverse("web_store_marketing"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_marketing")
        
        response = self.client.get(reverse("web_store_shows"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_shows")
        
#        response = self.client.get(reverse("web_store_theme"), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_theme")
        
        response = self.client.get(reverse("web_store_pages"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_pages")
        
        response = self.client.get(reverse("web_store_blogs"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_blogs")
        
        response = self.client.get(reverse("web_store_navigation"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach web_store_navigation")
        
#        response = self.client.get(reverse("web_store_show_go"), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
#        
#        response = self.client.get(reverse("web_store_show_not_go"), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
#        
#        response = self.client.get(reverse("web_store_theme"), HTTP_HOST=HTTP_HOST)
#        self.assertEqual(response.status_code, 200, "Failed when trying to bid a valid amount")
        
        ######### INVENTORY ##########
        response = self.client.get(reverse("inventory"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory")
        
        response = self.client.get(reverse("inventory_overview"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_overview")
        
        response = self.client.get(reverse("inventory_items"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_items")
        
        response = self.client.get(reverse("inventory_items_import"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_items_import")
        
        response = self.client.get(reverse("inventory_lots"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_lots")
                
        response = self.client.get(reverse("inventory_auctions"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_auctions")
        
        response = self.client.get(reverse("inventory_categorize"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach inventory_categorize")
        
        ######## ACCOUNT #########
        response = self.client.get(reverse("account"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach account")
        
        response = self.client.get(reverse("account_profile"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach account_profile")
        
        response = self.client.get(reverse("account_password"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach account_password")
        
        response = self.client.get(reverse("add_profile_photo"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 302, "Failed when trying to reach add_profile_photo")
        
        response = self.client.get(reverse("preferences"), HTTP_HOST=HTTP_HOST)
        self.assertEqual(response.status_code, 200, "Failed when trying to reach preferences")