Example #1
0
 def test_product(self):
     from main import product
     self.assertEqual(product((1, 2, 3, 4)), 24, "Произведение 1,2,3,4")
     self.assertEqual(product((100, 3, 11, 24)), 79200,
                      "Произведение 100,3,11,24")
     self.assertEqual(product((1.2, 2.5, -2, 45)), -270,
                      "Произведение 1.2,2.5,-2,45")
     self.assertEqual(product((1, 0, 3, 4)), 0, "Произведение 1,0,3,4")
Example #2
0
def compute():

    for x in xrange(50):

        p=product()
        a=['silver','gold','platinum']
        bids=random.randrange(0,20)
        c=customer(random.choice(a),bids)


        pmd=random.randrange(0,25)
        sales=random.randrange(500,2000)
        q=plot(sales,pmd)

        #random.normalvariate(random.randrange(500,1050,100),random.randrange(50,105,10))

        p.inventory.cur=random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))

        p.inventory.maxi=random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))

        p.number_items_dp=abs(p.inventory.maxi-p.inventory.cur)

        p.revenue.dp=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))

        p.revenue.cp=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))

        p.price.cost=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))

        p.price.selling=random.normalvariate(random.randrange(600+(x%20),1650+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))

        #p.bids.cur=random.randrange(0,5)

        # call to database for total number of bids made
        #p.bids.tot=p.bids.cur+random.randrange(0,5)

        #p.inventory.t0=p.inventory.cur + random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))
        p.inventory.t0=p.inventory.cur
        #Inserting into the db
        print d.insert(db_name,'inventory',p.inventory.to_JSON())
        print d.insert(db_name,'revenue',p.revenue.to_JSON())
        print d.insert(db_name,'price',p.price.to_JSON())
        print d.insert(db_name,'bids',p.bids.to_JSON())
        print d.insert(db_name,'product',p.to_JSON())
        print d.insert(db_name,'customer',c.to_JSON())
        print d.insert(db_name,'plot',q.to_JSON())
        print d.insert(db_name,'customer',c.to_JSON())

        # print d.update_with_date_random(db_name,'revenue',p.revenue.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'price',p.price.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'bids',p.bids.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'product',p.to_JSON(),p.id-1)


    return
Example #3
0
def compute():

    for x in xrange(20):

        p = product()
        a = ['silver', 'gold', 'platinum']
        bids = random.randrange(0, 20)
        c = customer(random.choice(a), bids)

        pmd = random.randrange(0, 25)
        sales = random.randrange(500, 2000)
        q = plot(sales, pmd)

        p.inventory.cur = random.randrange(
            random.randrange(1 + (x % 20), 10 + (x % 20), 2),
            random.randrange(22 + (x % 20), 500 + (x % 20), 7),
            random.randrange(1, 3, 1))

        p.inventory.maxi = random.randrange(
            random.randrange(1 + (x % 20), 10 + (x % 20), 2),
            random.randrange(22 + (x % 20), 500 + (x % 20), 7),
            random.randrange(1, 3, 1))

        p.revenue.dp = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        p.revenue.cp = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        p.price.cost = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        #p.price.selling=random.normalvariate(random.randrange(600+(x%20),1650+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))

        p.inventory.t0 = p.inventory.cur
        #Inserting into the db
        print d.insert(db_name, 'inventory', p.inventory.to_JSON())
        print d.insert(db_name, 'revenue', p.revenue.to_JSON())
        print d.insert(db_name, 'price', p.price.to_JSON())
        print d.insert(db_name, 'bids', p.bids.to_JSON())
        print d.insert(db_name, 'product', p.to_JSON())
        print d.insert(db_name, 'customer', c.to_JSON())
        print d.insert(db_name, 'plot', q.to_JSON())
        print d.insert(db_name, 'customer', c.to_JSON())

        # print d.update_with_date_random(db_name,'revenue',p.revenue.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'price',p.price.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'bids',p.bids.to_JSON(),p.id-1)
        # print d.update_with_date_random(db_name,'product',p.to_JSON(),p.id-1)

    return
def compute():

    for x in xrange(200):

        p=product()
        
        random.normalvariate(random.randrange(500,1050,100),random.randrange(50,105,10))

        # call to database to get inventory for this product at this time
        p.inventory.cur=random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))       
        
        # call to database to get max inventory capacity of this product
        p.inventory.maxi=random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))      
        
        # call to databse to get revenue under dynamic pricing for this product
        p.revenue.dp=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))           
        
        # call to databse to get revenue under regular pricing for this product
        p.revenue.cp=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))         
        
        # call to database to get cost price of this item
        p.price.cost=random.normalvariate(random.randrange(500+(x%20),1550+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))         
        
        # call to database to get cost price of this item
        p.price.selling=random.normalvariate(random.randrange(600+(x%20),1650+(x%20),30),random.randrange(50+(x%20),105+(x%20),10))         
        
        # call to database for number of bids made so far for this item
        p.bids.cur=random.randrange(0,5)         

        # call to database for total number of bids made
        p.bids.tot=p.bids.cur+random.randrange(0,5)

        # call to database to get inventory for this item at the beginning of the day
        p.inventory.t0=p.inventory.cur + random.randrange(random.randrange(1+(x%20),10+(x%20),2),random.randrange(22+(x%20),500+(x%20),7), random.randrange(1,3,1))
        
        #Inserting into the db
    
        print d.insert('test3','revenue',p.revenue.to_JSON())
        print d.insert('test3','price',p.price.to_JSON())
        print d.insert('test3','bids',p.bids.to_JSON())
        print d.insert('test3','product',p.to_JSON())    

        print d.update_with_date_random('test3','revenue',p.revenue.to_JSON(),p.id-1)    
        print d.update_with_date_random('test3','price',p.price.to_JSON(),p.id-1)    
        print d.update_with_date_random('test3','bids',p.bids.to_JSON(),p.id-1)    
        print d.update_with_date_random('test3','product',p.to_JSON(),p.id-1)    
     
    
    return
Example #5
0
def compute():

    for x in xrange(200):

        p = product()

        random.normalvariate(random.randrange(500, 1050, 100),
                             random.randrange(50, 105, 10))

        # call to database to get inventory for this product at this time
        p.inventory.cur = random.randrange(
            random.randrange(1 + (x % 20), 10 + (x % 20), 2),
            random.randrange(22 + (x % 20), 500 + (x % 20), 7),
            random.randrange(1, 3, 1))

        # call to database to get max inventory capacity of this product
        p.inventory.maxi = random.randrange(
            random.randrange(1 + (x % 20), 10 + (x % 20), 2),
            random.randrange(22 + (x % 20), 500 + (x % 20), 7),
            random.randrange(1, 3, 1))

        # call to databse to get revenue under dynamic pricing for this product
        p.revenue.dp = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        # call to databse to get revenue under regular pricing for this product
        p.revenue.cp = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        # call to database to get cost price of this item
        p.price.cost = random.normalvariate(
            random.randrange(500 + (x % 20), 1550 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        # call to database to get cost price of this item
        p.price.selling = random.normalvariate(
            random.randrange(600 + (x % 20), 1650 + (x % 20), 30),
            random.randrange(50 + (x % 20), 105 + (x % 20), 10))

        # call to database for number of bids made so far for this item
        p.bids.cur = random.randrange(0, 5)

        # call to database for total number of bids made
        p.bids.tot = p.bids.cur + random.randrange(0, 5)

        # call to database to get inventory for this item at the beginning of the day
        p.inventory.t0 = p.inventory.cur + random.randrange(
            random.randrange(1 + (x % 20), 10 + (x % 20), 2),
            random.randrange(22 + (x % 20), 500 +
                             (x % 20), 7), random.randrange(1, 3, 1))

        #Inserting into the db

        print d.insert('test3', 'revenue', p.revenue.to_JSON())
        print d.insert('test3', 'price', p.price.to_JSON())
        print d.insert('test3', 'bids', p.bids.to_JSON())
        print d.insert('test3', 'product', p.to_JSON())

        print d.update_with_date_random('test3', 'revenue',
                                        p.revenue.to_JSON(), p.id - 1)
        print d.update_with_date_random('test3', 'price', p.price.to_JSON(),
                                        p.id - 1)
        print d.update_with_date_random('test3', 'bids', p.bids.to_JSON(),
                                        p.id - 1)
        print d.update_with_date_random('test3', 'product', p.to_JSON(),
                                        p.id - 1)

    return
Example #6
0
def test_product_case2():
    assert product(1, 21) == "Odd"
Example #7
0
def test_product_case1():
    assert product(3, 4) == "Even"