Ejemplo n.º 1
0
    def test_close_connection(self):
        foo = DB("bar")
        foo.conn = fake_connection()

        foo.close_connection()

        assert foo.conn is None
Ejemplo n.º 2
0
    def test_query(self):
        foo = DB("bar")
        foo.conn = fake_connection()

        bar = foo.query("some query")

        assert bar == True
        assert foo.conn.called_execute == True
Ejemplo n.º 3
0
    def test_insertupdate(self):
        foo = DB("bar")
        foo.conn = fake_connection()

        foo.insertupdate("some query", ["val1", "val2"])

        assert foo.conn.called_close == False
        assert foo.conn.called_commit == True
        assert foo.conn.fake_cursor.called_execute == True
Ejemplo n.º 4
0
    def test_execute(self):
        foo = DB("bar")
        foo.conn = fake_connection_2()

        foo.execute("fake query")

        assert foo.conn.called_close == False
        assert foo.conn.called_commit == True
        assert foo.conn.called_execute == False
        assert foo.conn.fake_cursor.called_execute == True
Ejemplo n.º 5
0
    def test_insertupdate_catches_exception(self):
        foo = DB("bar")
        foo.conn = fake_failed_connection()

        bar = foo.insertupdate("some query", ["val1", "val2"])
        assert bar == None