Ejemplo n.º 1
0
    def test_insert_check_default_values(self, connection):

        mro.load_database(connection)

        table_count = mro.table1.select_count()

        table = mro.table1(column1 = 3, column2 = 'Hi!')

        table = mro.table1(column1 = 3, column2 = 'Hi!', column3 = 11, created_date = datetime.now().date())

        tables = mro.table1.select()

        for table in tables:
            assert isinstance(table.id, int)
            assert table.id != None
            assert isinstance(table.created_date, date)
            assert table.created_date != None
            assert isinstance(table.column1, int)
            assert table.column1 != None
            assert isinstance(table.column2, str)
            assert table.column2 != None
            assert table.column3 == None or isinstance(table.column3, int)

        table = mro.table3(column3 = 'Hi56!', column4 = '{"data": 1}')

        table = mro.table3.select_one("column3 = 'Hi56!'")

        assert isinstance(table.column1, str)
        assert table.column1 == 'ABC DEF'
        assert isinstance(table.column3, str)
        assert table.column3 != None
        assert isinstance(table.column4, str)
        assert table.column4 != None
Ejemplo n.º 2
0
 def test_insert_class_that_has_foreign_references(self, connection):
     mro.table1(name = 'Bob')
     table = mro.table3(name = 'Bob2')
     # test that it's a varchar not a foreign key reference
     table.table4s = 'test string'
Ejemplo n.º 3
0
    def test_update_fails_with_no_primary_key(self, connection):

        table = mro.table3(value='first')
        with pytest.raises(ValueError) as excinfo:
            table.value = 'second'
        assert excinfo.value.args[0] == "Update needs columns to match to update, is your table missing a prmary key?"