Exemplo n.º 1
0
 def test_create_storage(self):
     """Test the fact of storage creation."""
     m = Model()
     file_name = './file.sme.sqlite'
     remove_file(file_name)
     m.create_storage(file_name)
     exists = os.path.isfile(file_name)
     remove_file(file_name)
     self.assertEqual(exists, True)
Exemplo n.º 2
0
 def test_create_storage_in_home_dir(self):
     """Test the fact of storage creation."""
     m = Model()
     file_name = '~/file.sme.sqlite'
     remove_file(file_name)
     m.create_storage(file_name)
     exists = os.path.isfile(os.path.expanduser(file_name))
     remove_file(file_name)
     self.assertEqual(exists, True)
Exemplo n.º 3
0
 def test_create_storage_if_exists(self):
     """If file file_name exists it should be correctly replaced by new storage."""
     m = Model()
     file_name = './copy-test.sme.sqlite'
     shutil.copy2('./test.sme.sqlite', file_name)
     m.create_storage(file_name)
     m.close_storage()
     conn = sqlite3.connect(file_name)
     c = conn.cursor()
     c.execute("select count(*) from examination")
     n = c.fetchone()[0]
     conn.close()
     remove_file(file_name)
     self.assertEqual(n, 0)
Exemplo n.º 4
0
 def test_insert_examination_to_new_storage(self):
     """Number of examination must be 1 after insertion examination to new empty storage."""
     m = Model()
     file_name = './copy-test.sme.sqlite'
     m.create_storage(file_name)
     m.insert_exam(create_test_exam())
     m.close_storage()
     conn = sqlite3.connect(file_name)
     c = conn.cursor()
     c.execute("select count(*) from examination")
     n = c.fetchone()[0]
     conn.close()
     remove_file(file_name)
     self.assertEqual(n, 1)