Ejemplo n.º 1
0
 def test_get_ungrouped(self):
     """Storage info result must be not empty if storage was opened."""
     m = Model()
     m.open_storage('./test.sme.sqlite')
     data, headers = m.group_info('0')
     self.assertNotEqual(data, None)
     self.assertNotEqual(headers, None)
Ejemplo n.º 2
0
 def test_open_stoarge_home_dir(self):
     """Copy test database to ~ and try to open it."""
     file_name = "~/test.sme.sqlite"
     abs_file_name = os.path.expanduser(file_name)
     remove_file(abs_file_name)
     shutil.copy2('./test.sme.sqlite', abs_file_name)
     m = Model()
     m.open_storage(abs_file_name)
     result = m.state()['storage_opened']
     m.close_storage()
     remove_file(abs_file_name)
     self.assertTrue(result)
Ejemplo 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)
Ejemplo n.º 4
0
 def test_extract_exams_multiple_ids(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.extract_exams(['1', '0', '0', '1', '0'])
     m.close_storage()
     self.assertEqual(len(es), 3)
Ejemplo n.º 5
0
 def test_extract_exams_union_ungrouped_and_other(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.extract_exams(['1', '0'])
     m.close_storage()
     self.assertEqual(len(es), 3)
Ejemplo n.º 6
0
 def test_extract_exams_single_id_default_union(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.extract_exams(['1'])
     m.close_storage()
     self.assertEqual(len(es), 2)
Ejemplo n.º 7
0
 def test_extract_exams_union(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.extract_exams(['1', '2'], 'union')
     m.close_storage()
     self.assertEqual(len(es), 3)
Ejemplo n.º 8
0
 def test_exams_not_existing_group_id(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.exams('1000')
     m.close_storage()
     self.assertEqual(es, None)
Ejemplo n.º 9
0
 def test_exams_length_of_result_group_1(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     es = m.exams('1')
     m.close_storage()
     self.assertEqual(len(es), 2)
Ejemplo n.º 10
0
 def test_group_info_if_group_does_not_exist(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     data, headers = m.group_info('1000')
     self.assertEqual(data, None)
     self.assertEqual(headers, None)
Ejemplo n.º 11
0
 def test_group_info_by_existing_not_zero_id(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     data, headers = m.group_info(1)
     self.assertNotEqual(data, None)
     self.assertNotEqual(headers, None)
Ejemplo n.º 12
0
 def test_storage_info(self):
     m = Model()
     m.open_storage('./test.sme.sqlite')
     data, headers = m.storage_info()
     self.assertEqual(len(data) > 0, True)
     self.assertEqual(len(headers) > 0, True)
Ejemplo n.º 13
0
 def test_get_no_existing_examination(self):
     """Try to get examination from data base by no existing exam_id."""
     m = Model()
     m.open_storage('./test.sme.sqlite')
     e = m.exam(1000)
     self.assertEqual(e, None)
Ejemplo n.º 14
0
 def test_get_examination(self):
     """Get examination by ID from data base."""
     m = Model()
     m.open_storage('./test.sme.sqlite')
     e = m.exam(1)
     self.assertEqual(len(e.ms), 2)
Ejemplo n.º 15
0
 def test_get_examination_naive(self):
     """Get examination record by ID from data base."""
     m = Model()
     m.open_storage('./test.sme.sqlite')
     e = m.exam(1)
     self.assertNotEqual(e, None)