def test_create_by_file_encoded_an_set_runtime_path(self): self.filename = "b64pyshell.txt" runtime_path = "C:\\Users\\burtnolej" append_text_to_file( self.filename, "database_name:" + b64encode(self.database_name) + "\n") append_text_to_file(self.filename, "table_name:" + b64encode(self.table_name) + "\n") append_text_to_file(self.filename, "delete_flag:" + b64encode("False") + "\n") append_text_to_file( self.filename, "column_defns:" + "$$".join([ b64encode(_name) + "^" + b64encode(_type) for _name, _type in self.column_defn ]) + "\n") DatabaseCreateTable.create_by_file(self.filename, runtime_path=runtime_path) database = Database( runtime_path + "\\" + self.database_name + ".sqlite", True) with database: self.assertTrue(tbl_exists(database, self.table_name)) os_file_delete(self.filename)
def persist(self, createtable=True): self._metadata_set() if not tbl_exists(self.database, self.tbl_name) == True: tbl_create(self.database, self.tbl_name, self.tbl_col_defn) result, exec_str = tbl_rows_insert(self.database, self.tbl_name, self.tbl_col_names, self.tbl_row_values) return (result, exec_str)
def test_create_by_file(self): append_text_to_file(self.filename, "database_name:" + self.database_name + "\n") append_text_to_file(self.filename, "table_name:" + self.table_name + "\n") append_text_to_file(self.filename, "delete_flag:False" + "\n") append_text_to_file( self.filename, "column_defns:" + "$$".join( [_name + "^" + _type for _name, _type in self.column_defn]) + "\n") DatabaseCreateTable.create_by_file(self.filename) database = Database(self.database_name, True) with database: self.assertTrue(tbl_exists(database, self.table_name)) os_file_delete(self.filename)
def test_create_by_file_encoded(self): self.filename = "b64pyshell.txt" append_text_to_file( self.filename, "database_name:" + b64encode(self.database_name) + "\n") append_text_to_file(self.filename, "table_name:" + b64encode(self.table_name) + "\n") append_text_to_file(self.filename, "delete_flag:" + b64encode("False") + "\n") append_text_to_file( self.filename, "column_defns:" + "$$".join([ b64encode(_name) + "^" + b64encode(_type) for _name, _type in self.column_defn ]) + "\n") DatabaseCreateTable.create_by_file(self.filename) database = Database(self.database_name, True) with database: self.assertTrue(tbl_exists(database, self.table_name)) os_file_delete(self.filename)
def test_create(self): DatabaseCreateTable.create(self.database_name, self.table_name, self.column_defn) database = Database(self.database_name, True) with database: self.assertTrue(tbl_exists(database, self.table_name))
def _table_exists(self, table_name): with self.database: return (tbl_exists(self.database, table_name))
def test_tbl_exists_false(self): database = Database(test_db.name, True) with database: self.assertFalse(tbl_exists(database, 'foobar'))
def test_tbl_exists(self): database = Database(test_db.name, True) with database: self.assertTrue(tbl_exists(database, 'tbl_name_test'))