From f201ab603d97fc912fea6d773ca7b97cd822b7ba Mon Sep 17 00:00:00 2001 From: Darksider3 Date: Mon, 8 Jun 2020 14:34:59 +0200 Subject: [PATCH] tests: Add initial infrastructure! Tests now can be done with `python -m test.test_backup --verbose`! Im going to add more tests as coverage as soon as i've got time! :) --- private/test/__init__.py | 0 private/test/applications.sqlite | Bin 0 -> 12288 bytes private/test/test_backup.py | 45 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 private/test/__init__.py create mode 100644 private/test/applications.sqlite create mode 100644 private/test/test_backup.py 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 0000000000000000000000000000000000000000..18398950eb6a22d96b4b96d05fdfeefe61092107 GIT binary patch literal 12288 zcmeI&J#W)M90u^aI4bQx(yc?6V~EtMNr`PbBrG+Jfrz}}oCRU2-1v&D_$9S3psw&u z_yX{$7@7D0oYST44bQn1S;jXcRrvP&o>r;HIowA({9 z%cAOBzU}8te*LG?NaO3)eKo68`9vz;)d>Xw2tWV=5P$##AOHafKmY;|*eEb6ZS5T$ z(TVgfLXlmCYP))#iK~T(r|Xy6nPXerX54zxv)S6*gV>8iU9CL)utV?d)oS#kyUg_F z^DvltGDzaA*f0H*R{ZB6@L6}j?Ps>bMozbHITQB6o-oVh!|p&W>)QifUt}W9@5#9R znzO-B9d55zXCm@~aBXnYy!ql{Ca%{e${-S%^rAWIs5j-^zRf!JQ_JmfcIG;cy6<^D zIObM=RA*|YTx568x_XAYCC$TpZ(go^A=S^-H&v=SCutT&J~3WtD)8~izPa651?q7k)pkEk-U;8hiA|5EN#w?>QFfC*NQ{laMzd`` z8kbaX>tQk2Co?(P8q literal 0 HcmV?d00001 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()