diff --git a/private/test/__init__.py b/private/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/private/test/applications.sqlite b/private/test/applications.sqlite new file mode 100644 index 0000000..1839895 Binary files /dev/null and b/private/test/applications.sqlite differ diff --git a/private/test/test_backup.py b/private/test/test_backup.py new file mode 100644 index 0000000..757e1d4 --- /dev/null +++ b/private/test/test_backup.py @@ -0,0 +1,45 @@ +import sys + +sys.path.append('..') + +import unittest +from ListUsers import ListUsers +import backup + + +class TestBackup(unittest.TestCase): + test_csv: str = "test/testbackup.csv" + test_db: str = "./test/applications.sqlite" + + def setUp(self): + try: + self.fetch = ListUsers(self.test_db, unapproved=False, approved=False).get_fetch() + self.Backup = backup.Backup(self.test_csv) + except Exception as general_setup: + self.fail(f"Failed setup already! {general_setup}") + + def test_set_dialect(self): + pass + + def test_set_quoting(self): + pass + + def test_set_filename(self): + self.Backup.set_filename(self.test_csv) + self.assertEqual(self.Backup.filename, self.test_csv) + + def test_set_field_names(self): + # @TODO: Dynamic! Having a test scheme from which we setup our test is beneficial here, also values + self.Backup.set_field_names(self.fetch[0].keys()) + keys_found = self.Backup.field_names + self.assertEqual(keys_found, ['id', 'username', 'email', 'name', 'pubkey', 'timestamp', 'status']) + + def test_backup_to_file(self): + try: + self.Backup.backup_to_file(self.fetch) + except IOError as io_error: + self.fail(io_error) + + +if __name__ == '__main__': + unittest.main()