コード例 #1
0
ファイル: sqlite_unittest.py プロジェクト: dosadih/sqliteapi
class TestDelete(unittest.TestCase):
    """
    Testsuite 1 to test map function
    """
    def setUp(self):
        """
        Setup function launched before a testcase
        """
        self.dbpath = 'test/db.db3'
        self.unit = SQLiteAPI(verbose=1, dbpath=self.dbpath)
        self.unit.open()

    def tearDown(self):
        """
        tearDown function launched after a testcase
        """
        os.system("rm -fr " + self.dbpath)

    def test_delete_single_filter_success(self):
        """
        Simple test to be sure write function alive
        """
        # Build a table to store into the database
        table = {}
        table["name"] = "Pagees"
        table["column"] = []
        table["column"].append({"name" : 'name', "type" : "String"})
        table["column"].append({"name" : 'comment', "type" : "str"})
        table["column"].append({"name" : 'status', "type" : "int"})
        self.unit.create_table(table)
        item = {}
        item["status"] = "OK"
        self.unit.write(table=table["name"], item=item)
        self.assertEqual(0, self.unit.delete(table=table["name"], filters=item))


    def test_delete_multi_filters_success(self):
        """
        Simple test to be sure write function alive
        """
        # Build a table to store into the database
        table = {}
        table["name"] = "Pagees"
        table["column"] = []
        table["column"].append({"name" : 'name', "type" : "String"})
        table["column"].append({"name" : 'comment', "type" : "str"})
        table["column"].append({"name" : 'status', "type" : "int"})
        self.unit.create_table(table)
        item = {}
        item["name"] = "aParameter1"
        item["comment"] = "a status"
        item["status"] = "OK"
        self.unit.write(table=table["name"], item=item)
        self.assertEqual(0, self.unit.delete(table=table["name"], filters=item))
コード例 #2
0
ファイル: app.py プロジェクト: dosadih/sqliteapi
 
 os.system("rm -fr test/db.db3")
 API = SQLiteAPI(verbose=1, dbpath="test/db.db3")
 API.open()
 PAGE = {}
 PAGE["name"] = "Pagees"
 PAGE["column"] = []
 PAGE["column"].append({"name" : 'name', "type" : "String"})
 PAGE["column"].append({"name" : 'comment', "type" : "str"})
 PAGE["column"].append({"name" : 'status', "type" : "int"})
 API.create_table(PAGE)
 ITEM = {}
 ITEM["name"] = "aParameter1"
 ITEM["comment"] = "ThisIsAnUpdate"
 ITEM["status"] = "OK"
 API.write(table=PAGE["name"], item=ITEM)
 #API.write(table=PAGE["name"], item=ITEM)
 #ITEM = {}
 #ITEM["name"] = "aParameter2"
 #ITEM["comment"] = "ThisIsAnUpdate"
 #ITEM["status"] = "OK"
 #API.write(table=PAGE["name"], item=ITEM)
 #API.write(table=PAGE["name"], item=ITEM)
 #print API.read(table="Pagees", item=ITEM)
 ITEM = {}
 ITEM["name"] = "aParameter1"
 print API.read(PAGE["name"], item=ITEM)
 #ITEM["name"] = "aParameter1"
 #API.read(PAGE["name"], item=ITEM)
 #print API.read_column_info(PAGE["name"])
 API.exit()