Exemple #1
0
 def test_select_with_greater_equal_item_id(self):
     '''Test select with condtion: itemid >= 20'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     condition = "itemid >= 20"
     R1 = Table.select(R, condition)
     for row in R1.table:
         self.assertGreaterEqual(row['itemid'], 20)
Exemple #2
0
 def test_select_with_not_equal_item_id(self):
     '''Test select with condtion: itemid != 14'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     condition = "itemid != 14"
     R1 = Table.select(R, condition)
     for row in R1.table:
         self.assertNotEqual(row['itemid'], 14)
Exemple #3
0
 def test_select_with_equal_pricerange(self):
     '''Test select with condtion: pricerange = 'moderate'
     '''
     R = Table.inputfromfile('test_csv/sales1.csv')
     condition = "pricerange = 'moderate'"
     R1 = Table.select(R, condition)
     for row in R1.table:
         self.assertEquals(row['pricerange'], 'moderate')
Exemple #4
0
 def test_select_with_index_btree(self):
     """Test select with btree index on column pricerage"""
     R = Table.inputfromfile('test_csv/real_sales1.csv')
     condition = "pricerange = 'cheap'"
     start = time.time()
     for i in range(10):
         R1 = Table.select(R, condition)
     end = time.time()
     without_index = end - start
     Table.Btree(R, 'pricerange')
     start = time.time()
     for i in range(10):
         R1 = Table.select(R, condition)
     end = time.time()
     with_index = end - start
     for row in R1.table:
         self.assertEqual(row['pricerange'], 'cheap')
     self.assertLess(with_index, without_index / 5)
Exemple #5
0
 def test_select_with_multiple_condition(self):
     '''Test select with condtion: itemid >= 20 and pricerange == 'moderate'
     '''
     R = Table.inputfromfile('test_csv/sales1.csv')
     condition = "(itemid >= 20) and (pricerange == 'moderate')"
     R1 = Table.select(R, condition)
     for row in R1.table:
         self.assertGreaterEqual(row['itemid'], 20)
         self.assertEquals(row['pricerange'], 'moderate')
 def test_select_with_equal_id(self):
     '''Test select with condtion: saleid = 36'''
     R = Table.inputfromfile('sales1')
     condition = 'saleid = 36'
     R1 = Table.select(R,condition)
     self.assertIsNotNone(R1.table[0])
     self.assertEqual(R1.table[0]['saleid'],36)
     self.assertEqual(R1.table[0]['itemid'],14)
     self.assertEqual(R1.table[0]['customerid'],2)
     self.assertEqual(R1.table[0]['storeid'],38)
     self.assertEqual(R1.table[0]['time'],49)
     self.assertEqual(R1.table[0]['qty'],15)
     self.assertEqual(R1.table[0]['pricerange'],'moderate')
     self.assertEqual(len(R1.table),1)
Exemple #7
0
 def test_select_with_equal_id(self):
     '''Test select with condtion: saleid = 36'''
     self.R = Table.inputfromfile('test_csv/sales1.csv')
     condition = 'saleid = 36'
     self.R1 = Table.select(self.R, condition)
     self.assertIsNotNone(self.R1.table[0])
     expected = {
         'saleid': 36,
         'itemid': 14,
         'customerid': 2,
         'storeid': 38,
         'time': 49,
         'qty': 15,
         'pricerange': 'moderate'
     }
     self.assertEqual(self.R1.table[0], expected)
     self.assertEqual(len(self.R1.table), 1)