def test_tag_relation_export(self): # Insert and then retrieve tag-relations. _, _ = lgd.tag_import(self.conn, get_tag_csv()) tag_relations1 = set(lgd.select_related_tags_all(self.conn)) self.assertEqual(len(tag_relations1), len(TAG_RELATIONS)) # Export tag-relations from the initial DB. tagfile = io.StringIO() _ = lgd.tag_export(self.conn, tagfile) tagfile.seek(0) # Set up a second DB. # Import tag-relations from the 1st DB into the 2nd. conn2 = lgd.get_connection(DB_IN_MEM) lgd.db_setup(conn2, lgd.DB_MIGRATIONS) _, _ = lgd.tag_import(conn2, tagfile) # Retrieve the tag-relations from the 2nd DB. # Check that the tag-relations retrieved from both DBs are equal. tag_relations2 = set(lgd.select_related_tags_all(conn2)) self.assertEqual(tag_relations1, tag_relations2)
def test_note_export_equality(self): # Retrieve Notes inserted during setup. notes1 = set(lgd.select_notes(self.conn)) self.assertEqual(len(notes1), len(NOTES)) # Export from the setUp DB. notes = lgd.select_notes(self.conn, localtime=False) notefile = io.StringIO() _ = lgd.note_export(self.conn, notes, notefile) notefile.seek(0) # Set up a second DB conn2 = lgd.get_connection(DB_IN_MEM) lgd.db_setup(conn2, lgd.DB_MIGRATIONS) # Import the Notes from the 1st DB into the 2nd. _, _ = lgd.note_import(conn2, notefile) # Retrieve the Notes from the 2nd DB. # Check that the notes retrieved from both DBs are equal. notes2 = set(lgd.select_notes(conn2)) self.assertEqual(notes1, notes2)
def setUp(self): self.conn = lgd.get_connection(DB_IN_MEM) lgd.db_setup(self.conn, lgd.DB_MIGRATIONS)
def setUp(self): self.conn = lgd.get_connection(DB_IN_MEM) lgd.db_setup(self.conn, lgd.DB_MIGRATIONS) self.inserted, self.updated = lgd.note_import(self.conn, get_note_csv())
def setUp(self): self.conn = lgd.get_connection(DB_IN_MEM)