Пример #1
0
 def test_distinct(self):
     self.workspace.numbers(self.workspace.number_file)  # add duplicates
     q = catsql.connect(self.workspace.number_db)
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 10)
     q.distinct()
     self.assertEquals(len(q.rows.all()), 5)
Пример #2
0
 def test_distinct(self):
     self.workspace.numbers(self.workspace.number_file)  # add duplicates
     q = catsql.connect(self.workspace.number_db)
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 10)
     q.distinct()
     self.assertEquals(len(q.rows.all()), 5)
Пример #3
0
 def test_connect_column(self):
     q = catsql.connect(self.workspace.number_db, columns=['NAME'])
     q.order()
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 5)
     self.assertEquals(q.rows[0].NAME, 'five')
     with self.assertRaises(AttributeError):
         print(q.rows[0].DIGIT)
Пример #4
0
 def test_connect_column(self):
     q = catsql.connect(self.workspace.number_db, columns=['NAME'])
     q.order()
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 5)
     self.assertEquals(q.rows[0].NAME, 'five')
     with self.assertRaises(AttributeError):
         print(q.rows[0].DIGIT)
Пример #5
0
 def test_where_kv_with_expansion_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     codes = [
         {
             'CODE': '.',
         },
         {
             'CODE': '..'
         }
     ]
     fname = self.workspace.filename('code.txt')
     json.dump(codes, open(fname, 'w'))
     q.where_kv_with_expansion({'CODE': '@{}'.format(fname)})
     q.order(['CODE'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
Пример #6
0
 def test_where_kv_with_expansion_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     codes = [
         {
             'CODE': '.',
         },
         {
             'CODE': '..'
         }
     ]
     fname = self.workspace.filename('code.txt')
     json.dump(codes, open(fname, 'w'))
     q.where_kv_with_expansion({'CODE': '@{}'.format(fname)})
     q.order(['CODE'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
Пример #7
0
 def test_where_kv_with_expansion(self):
     q = catsql.connect(self.workspace.number_db)
     digits = [
         {
             'DIGIT': 2,
         },
         {
             'DIGIT': 3
         }
     ]
     fname = self.workspace.filename('digit.txt')
     json.dump(digits, open(fname, 'w'))
     q.where_kv_with_expansion({'DIGIT': '@{}'.format(fname)})
     q.order(['DIGIT'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
     self.assertEquals(q.rows[0].DIGIT, 2)
     self.assertEquals(q.rows[1].DIGIT, 3)
Пример #8
0
 def test_where_kv_with_expansion(self):
     q = catsql.connect(self.workspace.number_db)
     digits = [
         {
             'DIGIT': 2,
         },
         {
             'DIGIT': 3
         }
     ]
     fname = self.workspace.filename('digit.txt')
     json.dump(digits, open(fname, 'w'))
     q.where_kv_with_expansion({'DIGIT': '@{}'.format(fname)})
     q.order(['DIGIT'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
     self.assertEquals(q.rows[0].DIGIT, 2)
     self.assertEquals(q.rows[1].DIGIT, 3)
Пример #9
0
 def test_grep(self):
     q = catsql.connect(self.workspace.number_db)
     q.grep('wo')
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 1)
     self.assertEquals(q.row.NAME, 'two')
Пример #10
0
 def test_limit(self):
     q = catsql.connect(self.workspace.number_db)
     q.limit(2)
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
Пример #11
0
 def test_order_desc(self):
     q = catsql.connect(self.workspace.number_db)
     q.order(['NAME-'])
     self.assertEquals(q.rows[0].NAME, 'two')
Пример #12
0
 def test_order(self):
     q = catsql.connect(self.workspace.number_db)
     q.order(['NAME'])
     self.assertEquals(len(q), 1)
     self.assertEquals(q.rows[0].NAME, 'five')
Пример #13
0
 def test_where_sql_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     q.where_sql('CODE = "."')
     self.assertEquals(len(q), 1)
Пример #14
0
 def test_limit(self):
     q = catsql.connect(self.workspace.number_db)
     q.limit(2)
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 2)
Пример #15
0
 def test_order_desc(self):
     q = catsql.connect(self.workspace.number_db)
     q.order(['NAME-'])
     self.assertEquals(q.rows[0].NAME, 'two')
Пример #16
0
 def test_where_kv(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_kv({'DIGIT': 4})
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.DIGIT, 4)
Пример #17
0
 def test_where_sql(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_sql('DIGIT = 2')
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.NAME, 'two')
Пример #18
0
 def test_where_sql_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     q.where_sql('CODE = "."')
     self.assertEquals(len(q), 1)
Пример #19
0
 def test_where_kv(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_kv({'DIGIT': 4})
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.DIGIT, 4)
Пример #20
0
 def test_where_sqls(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_sqls(['DIGIT > 2', 'NAME like "%o%"'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.DIGIT, 4)
Пример #21
0
 def test_where_sql(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_sql('DIGIT = 2')
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.NAME, 'two')
Пример #22
0
 def test_grep(self):
     q = catsql.connect(self.workspace.number_db)
     q.grep('wo')
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q.rows.all()), 1)
     self.assertEquals(q.row.NAME, 'two')
Пример #23
0
 def test_where_sqls(self):
     q = catsql.connect(self.workspace.number_db)
     q.where_sqls(['DIGIT > 2', 'NAME like "%o%"'])
     self.assertEquals(len(q), 1)
     self.assertEquals(len(q[0]['rows'].all()), 1)
     self.assertEquals(q.row.DIGIT, 4)
Пример #24
0
 def test_where_kv_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     q.where_kv({'CODE': '.'})
     self.assertEquals(len(q), 1)
Пример #25
0
 def test_where_kv_multiple_tables(self):
     self.workspace.add_product_table()
     q = catsql.connect(self.workspace.number_db)
     q.where_kv({'CODE': '.'})
     self.assertEquals(len(q), 1)
Пример #26
0
 def test_order(self):
     q = catsql.connect(self.workspace.number_db)
     q.order(['NAME'])
     self.assertEquals(len(q), 1)
     self.assertEquals(q.rows[0].NAME, 'five')
Пример #27
0
 def test_connect_table(self):
     self.workspace.numbers(self.workspace.number_file, 'more')
     q = catsql.connect(self.workspace.number_db)
     self.assertEquals(len(q), 2)
     q = catsql.connect(self.workspace.number_db, tables=['more'])
     self.assertEquals(len(q), 1)
Пример #28
0
 def test_connect_table(self):
     self.workspace.numbers(self.workspace.number_file, 'more')
     q = catsql.connect(self.workspace.number_db)
     self.assertEquals(len(q), 2)
     q = catsql.connect(self.workspace.number_db, tables=['more'])
     self.assertEquals(len(q), 1)