def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False try: a_table.add_column('col', 'invalid') except: error = True if not error: self.fail("Chamada não gerou erro mas deveria!") def test_add_erlationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table =DataTable('B') b_table.add_column('BId', 'bigint') a_table.add_references('B', b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced)) def test_add_reverse_relationship(self): a_table = DataTable('A') col = a_table.add_column('Bid', 'bigint') b_table = DataTable('B') col = b_table.add_column('BId', 'bigint') b_table.add_referenced('A', a_table, col) self.assertEqual(1, len(b_table.referenced)) self.assertEqual(0, len(b_table.references))
def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False try: a_table.add_column('col', 'invalid') except: error = True if not error: self.fail("Chamada não gerou erro mas deveria")
def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False try: a_table.add_column('col', 'invalid') except Exception: error = True if not error: self.fail("Chamada não gerou erro mas deveria")
def test_add_relationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table = DataTable('B') b_table.add_column('BId', 'bigint') a_table.add_references('B', b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced))
class DataTableTest (unittest.TestCase): def setUp(self): self.addCleanup(self.my_cleanup, "Executando Cleanup") self.table = DataTable("A") def my_cleanup(self, msg): print(msg) def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column('BId', 'bigint') self.assertEqual(1, len(self.table._columns)) self.table.add_column('value', 'numeric') self.assertEqual(2, len(self.table._columns)) self.table.add_column('desc', 'varchar') self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ('col', 'invalid')) def test_add_column_type_fail(self): error = False try: self.table.add_column('col', 'invalid') except: error = True if not error: self.fail("Chamada não gerou erro, mas deveria")
def setUp(self): try: self.table = DataTable("Teste") # método que sempre será executado a cada "troca de testes" independente de algum erro não tratado ocorrer no setUp self.addCleanup(self.my_cleanup, ("cleanup executado")) self.out_file = open() except Exception as ex: pass
def test_add_erlationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table =DataTable('B') b_table.add_column('BId', 'bigint') a_table.add_references('B', b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced))
def test_add_relationship(self): a_table = DataTable("A") col = a_table.add_column("BId", "bigint") b_table = DataTable("B") b_table.add_column("BId", "bigint") a_table.add_references("B", b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced))
class DataTableTest(unittest.TestCase): def setUp(self): self.table = DataTable('A') def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column('Bid', 'bigint') self.assertEqual(1, len(self.table._columns)) self.table.add_column('Value', 'numeric') self.assertEqual(2, len(self.table._columns)) self.table.add_column('desc', 'varchar') self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ('col', 'invalid')) def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False try: a_table.add_column('col', 'invalid') except: error = True if not error: self.fail("Chamada não gerou erro mas deveria" def test_add_relationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table = DataTable('B') b_table.add_column('BId', 'bigint') a_table.add_references('B', b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced)) def test_add_reverse_relationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table = DataTable('B') col = b_table.add_column('BId', 'bigint') b_table.add_referenced('A', a_table, col) self.assertEqual(1, len(b_table.referenced)) self.assertEqual(0, len(b_table.references))
def test_add_reverse_relationship(self): a_table = DataTable('A') col = a_table.add_column('Bid', 'bigint') b_table = DataTable('B') col = b_table.add_column('BId', 'bigint') b_table.add_referenced('A', a_table, col) self.assertEqual(1, len(b_table.referenced)) self.assertEqual(0, len(b_table.references))
class DataTableTest2(unittest.TestCase): def setUp(self): self.table = DataTable('A') def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column('BId', 'bigint') self.assertEqual(1, len(self.table._columns)) self.table.add_column('value', 'numeric') self.assertEqual(2, len(self.table._columns)) self.table.add_column('desc', 'varchar') self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ('col', 'invalid')) def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False try: a_table.add_column('col', 'invalid') except: error = True if not error: self.fail("Chamada não gerou erro mas deveria") def test_add_relationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table = DataTable('B') b_table.add_column('BId', 'bigint') a_table.add_references('B', b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced)) def test_add_reverse_relationship(self): a_table = DataTable('A') col = a_table.add_column('BId', 'bigint') b_table = DataTable('B') col = b_table.add_column('BId', 'bigint') b_table.add_referenced('A', a_table, col) self.assertEqual(1, len(b_table.referenced)) self.assertEqual(0, len(b_table.references))
def main(): """table_empreendimento = DataTable("Empreendimento") col_id = table_empreendimento.add_column('IdEmnpreendimento','bigint') col_aditivo = table_empreendimento.add_column('IdAditivo','bigint') col_alerta = table_empreendimento.add_column('IdAlerta','bigint') table_aditivo = DataTable("Aditivo") col_id = table_aditivo.add_column('IdAtivo','bigint') col_emp_id = table_empreendimento.add_column('IdEmpreendimento','bigint') table_empreendimento.add_references('IdAditivo', table_aditivo, col_aditivo) table_aditivo.add_referenced('IdAditivo', table_empreendimento, col_emp_id) """ table = DataTable("Empreendimento") print(Column('IdEmpreendimento', 'bigint')) print(PrimaryKey(table, 'IdEmpreendimento', 'bigint')) if __name__ == '__main__': main()
class DataTableTeste(unittest.TestCase): def setUp(self): self.table = DataTable('A') def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column('BId', 'bigint') self.assertEqual(1, len(self.table._columns)) self.table.add_column('value', 'numeric') self.assertEqual(2, len(self.table._columns)) self.table.add_column('desc', 'varchar') self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ('col', 'invalid'))
class DataTableTest(unittest.TestCase): def setUp(self): self.table = DataTable('A') def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column('BId', 'bigint') self.assertEqual(1, len(self.table._columns)) self.table.add_column('value', 'numeric') self.assertEqual(2, len(self.table._columns)) self.table.add_column('desc', 'varchar') self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ('col', 'invalid'))
def setUp(self): self.table = DataTable('A')
class DataTableTest(unittest.TestCase): def setUp(self): try: self.table = DataTable("Teste") # método que sempre será executado a cada "troca de testes" independente de algum erro não tratado ocorrer no setUp self.addCleanup(self.my_cleanup, ("cleanup executado")) self.out_file = open() except Exception as ex: pass def test_add_column(self): self.assertEqual(0, len(self.table._columns)) self.table.add_column("BId", "bigint") self.assertEqual(1, len(self.table._columns)) self.table.add_column("value", "numeric") self.assertEqual(2, len(self.table._columns)) self.table.add_column("desc", "varchar") self.assertEqual(3, len(self.table._columns)) def test_add_column_invalid_type(self): self.assertRaises(Exception, self.table.add_column, ("col", "invalid")) # Parametros ( tipo de execao esperada, metodo chamado, tupla com argumentos para o metodo ) def test_add_column_invalid_type_fail(self): error = False try: self.table.add_column("col", "invalid") except Exception: error = True if not error: self.fail("Chamada não gerou um erro do tipo Exception") def test_add_relationship(self): a_table = DataTable("A") col = a_table.add_column("BId", "bigint") b_table = DataTable("B") b_table.add_column("BId", "bigint") a_table.add_references("B", b_table, col) self.assertEqual(1, len(a_table.references)) self.assertEqual(0, len(a_table.referenced)) def test_add_reverse_relationship(self): a_table = DataTable("A") col = a_table.add_column("BId", "bigint") b_table = DataTable("B") col = b_table.add_column("BId", "bigint") b_table.add_referenced("A", a_table, col) self.assertEqual(1, len(b_table.referenced)) self.assertEqual(0, len(b_table.references)) def my_cleanup(self, msg): """ Método que faz liberação de recursos, permitindo que ocorra erros dentro do setUp """ print(msg) def tearDown(self): """ Método que faz liberação de recursos, porém não é executado caso um erro não seja tratado no setUp """ pass
def test_add_column_invalid_type_fail(self): a_table = DataTable('A') error = False
def setUp(self): self.addCleanup(self.my_cleanup, "Executando Cleanup") self.table = DataTable("A")
def test_add_reverse_relationship(self): a_table = DataTable('A')
from domain import DataTable table_empreendimento = DataTable('Empreendimento') col_id = table_empreendimento.add_column('IdEmpreendimento', 'bigint') col_aditivo = table_empreendimento.add_column('IdAditivo', 'bigint') col_alerta = table_empreendimento.add_column('IdAlerta', 'bigint') table_aditivo = DataTable('Aditivo') col_id = table_aditivo.add_column('IdAdtivo', 'bigint') col_emp_id = table_empreendimento.add_column('IdEmpreendimento', 'bigint') table_empreendimento.add_references('IdAditivo', table_aditivo, col_aditivo) table_aditivo.add_column('IdEmpreendimento', table_empreendimento, col_emp_id)