Skip to content
Snippets Groups Projects
Commit f221dcef authored by morkolai's avatar morkolai
Browse files

#29 Test for oppdatering av kodeord

parent c765dc1b
No related branches found
No related tags found
1 merge request!15Kodebok-koder
Pipeline #72754 failed
......@@ -180,6 +180,24 @@ class DatabaseTest(unittest.TestCase):
self.assertRegex(actual[i]['code'], "[A-Z]{" + str(code_len) + "}")
self.assertEqual(entry['type'], actual[i]['type'])
def test_update_codebook(self):
"""Test that the codes get updated."""
# Get number of entries
stmt = 'SELECT COUNT(*) FROM CodeBook ORDER BY Word'
number_of_entries = self.database.conn.execute(stmt).fetchall()[0][0]
# Get old and updated word-code combinations
stmt = 'SELECT Word, Code FROM CodeBook'
old = self.database.conn.execute(stmt).fetchall()
self.database.update_codebook()
updated = self.database.conn.execute(stmt).fetchall()
# Collect approximately score of not updated pairs
pairs = 0
for i in range(0, number_of_entries, 2):
if old[i]['Code'] == updated[i]['Code']:
pairs = pairs + 1
# Test that at least some of the test are new
self.assertTrue(pairs < number_of_entries)
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment