Exemplo n.º 1
0
 def test_insert_examination_if_storage_was_not_open(self):
     """Insert examination method must return False if storage was not open."""
     m = Model()
     file_name = './copy-test.sme.sqlite'
     shutil.copy2('./test.sme.sqlite', file_name)
     try:
         m.insert_exam(create_test_exam())
         result = True
     except AttributeError:
         result = False
     finally:
         self.assertFalse(result)
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def test_insert_examination(self):
        """Number of examination must be increase after insert examination."""
        m = Model()
        file_name = './copy-test.sme.sqlite'
        shutil.copy2('./test.sme.sqlite', file_name)

        def get_len():
            conn = sqlite3.connect(file_name)
            c = conn.cursor()
            c.execute("select count(*) from examination")
            return c.fetchone()[0]
            conn.close()

        len_before = get_len()
        m.open_storage(file_name)
        m.insert_exam(create_test_exam())
        m.close_storage()
        len_after = get_len()
        remove_file(file_name)
        self.assertTrue(len_after > len_before)