Exemplo n.º 1
0
 def __tester_replace_filename():
     path = 'c:\\temp\\test_1.txt'
     filename = 'test_2.csv'
     path_test = u_file.replace_filename(path, filename)
     path_true = 'c:\\temp\\test_2.csv'
     p0 = path_test == path_true
     u_tester.run(p0)
Exemplo n.º 2
0
 def tester_select_from(self):
     q_test = Query()
     q_test.Select = 'col_1, col_2'
     q_test.From = 'tname'
     q_true = 'select col_1, col_2 from tname order by 1'
     p0 = str(q_test) == q_true
     u_tester.run([p0])
Exemplo n.º 3
0
 def __tester_factors():
     p0 = u_factor.factors(1) == {1}
     p1 = u_factor.factors(2) == {1, 2}
     p2 = u_factor.factors(3) == {1, 3}
     p3 = u_factor.factors(4) == {1, 2, 4}
     p4 = u_factor.factors(6) == {1, 2, 3, 6}
     u_tester.run(p0, p1, p2, p3, p4)
Exemplo n.º 4
0
 def __tester_load_stat():
     quest = Quest(qid=0,
                   qtype='SIMPLE',
                   priority='A',
                   topics=list(),
                   question='test',
                   answer_true='a',
                   answers_false=['b'])
     quest.load_stat(asked=0, answered=0, last_10=str(), last_time=1000)
     p0 = quest.grade = 100
     quest = Quest(qid=0,
                   qtype='SIMPLE',
                   priority='B',
                   topics=list(),
                   question='test',
                   answer_true='a',
                   answers_false=['b'])
     quest.load_stat(asked=0, answered=0, last_10=str(), last_time=1000)
     p1 = quest.grade = 90
     quest = Quest(qid=0,
                   qtype='SIMPLE',
                   priority='C',
                   topics=list(),
                   question='test',
                   answer_true='a',
                   answers_false=['b'])
     quest.load_stat(asked=1000,
                     answered=1000,
                     last_10='1111111111',
                     last_time=0)
     p2 = quest.grade = 1
     u_tester.run(p0, p1, p2)
Exemplo n.º 5
0
 def __tester_union():
     dict_1 = {'a': 1, 'b': 2}
     dict_2 = {'b': 2, 'c': 3}
     dict_test = u_dict.union(dict_1, dict_2)
     dict_true = {'a': 1, 'b': 2, 'c': 3}
     p0 = dict_test == dict_true
     u_tester.run(p0)
Exemplo n.º 6
0
 def __tester_h():
     ele_h = gen_tag.h(1)
     p0 = str(ele_h) == '<h1>\n</h1>'
     ele_text = Element(content='This is Header')
     ele_h.nest(ele_text)
     p1 = str(ele_h) == '<h1>\n\tThis is Header\n</h1>'
     u_tester.run(p0, p1)
Exemplo n.º 7
0
 def tester_df_to_signature_cols(self):
     dict_data = {'col_1': [1, 2], 'col_2': [1, 'a'], 'col_3': [1, 1.2]}
     df = pd.DataFrame(dict_data)
     signature_cols = Ora.df_to_signature_cols(df)
     signature_cols_true = 'col_1 int, col_2 varchar2(100), col_3 float'
     p0 = signature_cols == signature_cols_true
     u_tester.run(p0)
Exemplo n.º 8
0
 def __tester_eq():
     f1 = Fraction(1, 2)
     f2 = Fraction(1, 2)
     f3 = Fraction(1, 3)
     p0 = f1 == f2
     p1 = not f1 == f3
     u_tester.run(p0, p1)
Exemplo n.º 9
0
 def __tester_init():
     t = Topic(name='A -> B -> C', priority='ABA', i_row=8)
     p0 = t.name == 'A -> B -> C'
     p1 = t.priority == 'ABA'
     p2 = t.i_row == 8
     p3 = t.level == 2
     u_tester.run(p0, p1, p2, p3)
Exemplo n.º 10
0
 def tester_drop(self):
     u_ora.create_table_as('temp_u_ora', 'select * from dual')
     res_drop = u_ora.drop_table('temp_u_ora')
     p0 = True if res_drop else False
     res_drop = u_ora.drop_table('temp_u_ora')
     p1 = True if not res_drop else False
     u_tester.run([p0, p1])
Exemplo n.º 11
0
    def tester_run(self):
        res_0 = u_ora.run('select * from dual')
        p0 = True if res_0 else False
        res_1 = u_ora.run('xxx')
        p1 = True if not res_1 else False

        u_tester.run([p0, p1])
Exemplo n.º 12
0
    def tester_description(self):
        res_0 = u_ora.description('dual')
        p0 = True if res_0 else False
        res_1 = u_ora.description('table_not_exist')
        p1 = True if not res_1 else False

        u_tester.run([p0, p1])
Exemplo n.º 13
0
    def tester_close(self):
        ora = Ora()
        ora.open()
        res = ora.close()
        p0 = True if res else False

        u_tester.run(p0)
Exemplo n.º 14
0
 def __tester_to_str():
     dt = datetime.datetime(year=2020, month=9, day=15, hour=23, minute=59,
                     second=2)
     str_test = u_datetime.to_str(dt)
     str_true = '20200915235902'
     p0 = str_test == str_true
     u_tester.run(p0)
Exemplo n.º 15
0
 def __tester_normalize():
     f1 = Fraction(1, 2)
     f2 = Fraction(1, 3)
     f3, f4 = Fraction.normalize(f1, f2)
     p0 = f3 == Fraction(3, 6)
     p1 = f4 == Fraction(2, 6)
     u_tester.run(p0, p1)
Exemplo n.º 16
0
 def tester_to_key_value_str(self):
     dic = {'a': 1, 'b': 2}
     str_test = u_dict.to_key_value_str(dic)
     str_true = 'a="1", b="2"'
     p0 = str_test == str_true
     p1 = u_dict.to_key_value_str(dict()) == str()
     u_tester.run(p0, p1)
Exemplo n.º 17
0
 def tester_select(self):
     import pandas as pd
     res = u_ora.select('dual')
     df_true = pd.DataFrame.from_dict({'DUMMY': ['X']})
     p0 = res.val.equals(df_true)
     res = u_ora.select('select * from table not exist')
     p1 = True if not res else False
     u_tester.run([p0, p1])
Exemplo n.º 18
0
 def tester_orderby(self):
     q_test = Query()
     q_test.Select = 'col'
     q_test.From = 'tname'
     q_test.Orderby = 'col'
     q_true = 'select col from tname order by col'
     p0 = str(q_test) == q_true
     u_tester.run([p0])
Exemplo n.º 19
0
 def tester_having(self):
     q_test = Query()
     q_test.Select = 'col_1, max(col_2)'
     q_test.From = 'tname'
     q_test.Having = 'max(col_2)>=1'
     q_true = 'select col_1, max(col_2) from tname group by col_1 having max(col_2)>=1 order by 1'
     p0 = str(q_test) == q_true
     u_tester.run([p0])
Exemplo n.º 20
0
 def tester_get_empty_cols(self):
     tname = 'temp_tester_get_empty_cols'
     query = 'select dummy as col_1, cast(null as int) as col_2 from dual'
     u_ora.create_table_as(tname, query)
     empty_cols_test = u_ora.get_empty_cols(tname)
     empty_cols_true = {'col_2'}
     p0 = empty_cols_test == empty_cols_true
     u_tester.run([p0])
Exemplo n.º 21
0
 def __tester_is_proper():
     f0 = Fraction(1, 2)
     p0 = f0.is_proper()
     f1 = Fraction(1, 1)
     p1 = not f1.is_proper()
     f2 = Fraction(2, 1)
     p2 = not f2.is_proper()
     u_tester.run(p0, p1, p2)
Exemplo n.º 22
0
    def tester_val(self):
        res = Res(1)
        p0 = res.val == 1

        res = Res('Error', False)
        p1 = res.val is None

        u_tester.run([p0, p1])
Exemplo n.º 23
0
    def tester_empty(self):
        res = Res()
        p0 = True if res else False

        res = Res('Error', False)
        p1 = True if not res else False

        u_tester.run([p0, p1])
Exemplo n.º 24
0
    def tester_bool(self):
        res = Res(1, True)
        p0 = True if res else False

        res = Res('Error', False)
        p1 = True if not res else False

        u_tester.run([p0, p1])
Exemplo n.º 25
0
 def __tester_load_and_select():
     df_true = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
     sql = Sqlite()
     sql.load(df=df_true, tname='temp_1')
     df_test = sql.select(query='temp_1')
     sql.close()
     p0 = df_test.equals(df_true)
     u_tester.run(p0)
Exemplo n.º 26
0
 def __tester_decimal_point():
     d = Decimal(1)
     p0 = d.decimal_point() == 1
     d = Decimal(1.1)
     p1 = d.decimal_point() == 1
     d = Decimal(1.23)
     p2 = d.decimal_point() == 2
     u_tester.run(p0, p1, p2)
Exemplo n.º 27
0
 def tester_where(self):
     q_test = Query()
     q_test.Select = 'col_1'
     q_test.From = 'tname'
     q_test.Where = 'col_2=col_3'
     q_true = 'select col_1 from tname where col_2=col_3 order by 1'
     p0 = str(q_test) == q_true
     u_tester.run([p0])
Exemplo n.º 28
0
 def __tester_add():
     d1, d2 = Decimal(1), Decimal(2)
     p0 = d1 + d2 == 3.0
     d1, d2 = Decimal(1.2), Decimal(3.4)
     p1 = d1 + d2 == 4.6
     d1, d2 = Decimal(1.2), Decimal(3.45)
     p2 = d1 + d2 == 4.65
     u_tester.run(p0, p1, p2)
Exemplo n.º 29
0
 def __tester_sublist_by_index():
     # Simple Test
     li = ['a', 'b', 'c']
     indices = [0, 2]
     li_test = u_list.sublist_by_index(li, indices)
     li_true = ['a', 'c']
     p0 = li_test == li_true
     u_tester.run(p0)
Exemplo n.º 30
0
 def __tester_ctas():
     df = pd.DataFrame({'a': [1, 2, 3]})
     sql = Sqlite()
     sql.load(df=df, tname='temp_1')
     sql.ctas(tname='temp_2', query='select sum(a) as a from temp_1')
     df_test = sql.select(query='temp_2')
     df_true = pd.DataFrame({'a': [6]})
     p0 = df_test.equals(df_true)
     u_tester.run(p0)