Esempio n. 1
0
 def test_query_with_conditional_comparators(self):
     exp_e4 = ['10002004 | 1981 | 1',
               '10046101 | 1950 | 1']
     t_e4 = man.printable(consult.raw_query(self.e4, self.personas_tb))
     for s in exp_e4:
         self.assertIn(s, t_e4, '\nRaw query failed: \n'
                       'Expected:\n{0}\n'
                       'Test:\n{1}'.format(exp_e4, t_e4))
     exp_e5 = ['10003001 | 1933 | 1',
               '10002004 | 1981 | 1',
               '10002005 | 1995 | 1']
     t_e5 = man.printable(consult.raw_query(self.e5, self.personas_tb))
     for s in exp_e5:
         self.assertIn(s, t_e5, '\nRaw query failed: \n'
                       'Expected:\n{0}\n'
                       'Test:\n{1}'.format(exp_e5, t_e5))
     exp_e6 = ['338 | EL BOSQUE', '998 | NO ESPECIFICA']
     t_e6 = man.printable(consult.raw_query(self.e6, self.comunas_tb))
     for s in exp_e6:
         self.assertIn(s, t_e6, '\nRaw query failed: \n'
                       'Expected:\n{0}\n'
                       'Test:\n{1}'.format(exp_e6, t_e6))
     exp_e7 = ['10 | CALAMA', '13 | COPIAPO']
     t_e7 = man.printable(consult.raw_query(self.e7, self.comunas_tb))
     for s in exp_e7:
         self.assertIn(s, t_e7, '\nRaw query on e5 failed: \n'
                      'Expected:\n{0}\n'
                      'Test:\n{1}'.format(exp_e7, t_e7))
Esempio n. 2
0
def proc_consult_file(consult_file, result_file):
    tbs, consults = cns.get_consults(consult_file)
    result_f = open(result_file, 'a')

    for i in range(len(consults)):
        c = consults[i]
        hpr.log(TESTING, 'At consult: {0}'.format(c))
        to_file = '------- CONSULTA {0} -------\n'.format(i + 1)
        try:
            to_file += man.printable(cns.raw_query(c, tbs))
        except ValueError as ve:
            print('Error: {0}'.format(ve))
            to_file += 'FALLIDA'
        except hpr.InvalidQueryError as iqe:
            print('Error: {0}'.format(iqe))
            to_file += 'FALLIDA'
        except hpr.TerminateQueryError as tqe:
            print('Query terminated: {0}'.format(tqe))
            # Append an empty line
            to_file += '\n'
        except Exception as e:
            print('Error: {0}'.format(e))
            to_file += 'FALLIDA'
        finally:
            print('Completed consult {0}.'.format(i + 1))

        print(to_file, end='\n', file=result_f)
        hpr.log(TESTING, '\nConsult {0}: {1}'.format(i + 1, c))
        hpr.log(TESTING, to_file)
    result_f.close()
    return tbs
Esempio n. 3
0
def proc_consult_file(consult_file, result_file):
    tbs, consults = cns.get_consults(consult_file)
    result_f = open(result_file, 'a')

    for i in range(len(consults)):
        c = consults[i]
        hpr.log(TESTING, 'At consult: {0}'.format(c))
        to_file = '------- CONSULTA {0} -------\n'.format(i + 1)
        try:
            to_file += man.printable(cns.raw_query(c, tbs))
        except ValueError as ve:
            print('Error: {0}'.format(ve))
            to_file += 'FALLIDA'
        except hpr.InvalidQueryError as iqe:
            print('Error: {0}'.format(iqe))
            to_file += 'FALLIDA'
        except hpr.TerminateQueryError as tqe:
            print('Query terminated: {0}'.format(tqe))
            # Append an empty line
            to_file += '\n'
        except Exception as e:
            print('Error: {0}'.format(e))
            to_file += 'FALLIDA'
        finally:
            print('Completed consult {0}.'.format(i + 1))

        print(to_file, end='\n', file=result_f)
        hpr.log(TESTING, '\nConsult {0}: {1}'.format(i + 1, c))
        hpr.log(TESTING, to_file)
    result_f.close()
    return tbs
Esempio n. 4
0
def loop_consult(tbs, rows):
    in_loop = True

    while in_loop:
        query = input('\nPlease enter valid query:\n')
        if query:
            try:
                selected_rows = select_rows(cns.raw_query(query, tbs), rows)
                print(man.printable(selected_rows))
            except ValueError as ve:
                print('Error: {0}'.format(ve))
            except hpr.InvalidQueryError as iqe:
                print('Error: {0}'.format(iqe))
            except hpr.TerminateQueryError as tqe:
                print('\n')
            except Exception as e:
                print('Error: {0}'.format(e))
        else:
            in_loop = False
Esempio n. 5
0
def loop_consult(tbs, rows):
    in_loop = True

    while in_loop:
        query = input('\nPlease enter valid query:\n')
        if query:
            try:
                selected_rows = select_rows(cns.raw_query(query, tbs), rows)
                print(man.printable(selected_rows))
            except ValueError as ve:
                print('Error: {0}'.format(ve))
            except hpr.InvalidQueryError as iqe:
                print('Error: {0}'.format(iqe))
            except hpr.TerminateQueryError as tqe:
                print('\n')
            except Exception as e:
                print('Error: {0}'.format(e))
        else:
            in_loop = False