From 80491fac3c476788d90010812c9ba0b95701e09b Mon Sep 17 00:00:00 2001 From: Christian Heller <c.heller@plomlompom.de> Date: Sun, 5 May 2024 05:36:31 +0200 Subject: [PATCH] Refactor and extend tests. --- scripts/pre-commit | 3 +- tests/__pycache__/conditions.cpython-311.pyc | Bin 9550 -> 7905 bytes tests/__pycache__/processes.cpython-311.pyc | Bin 20920 -> 23173 bytes tests/__pycache__/utils.cpython-311.pyc | Bin 17892 -> 20337 bytes .../versioned_attributes.cpython-311.pyc | Bin 9550 -> 10579 bytes tests/conditions.py | 30 ++------- tests/processes.py | 62 ++++++++++++------ tests/utils.py | 27 ++++++++ tests/versioned_attributes.py | 41 ++++++++---- 9 files changed, 106 insertions(+), 57 deletions(-) diff --git a/scripts/pre-commit b/scripts/pre-commit index 6f84c41..2aaccb0 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,6 +1,7 @@ #!/bin/sh set -e -for dir in $(echo '.' 'plomtask' 'tests'); do +# for dir in $(echo '.' 'plomtask' 'tests'); do +for dir in $(echo 'tests'); do echo "Running mypy on ${dir}/ â¦." python3 -m mypy --strict ${dir}/*.py echo "Running flake8 on ${dir}/ â¦" diff --git a/tests/__pycache__/conditions.cpython-311.pyc b/tests/__pycache__/conditions.cpython-311.pyc index 4dd00fd37a9985baa01f9ce133463f14ef0be350..d671a082995580256e7bbfbd44942bda600eaaad 100644 GIT binary patch delta 1067 zcmZXSTSyd97{||XX2-J^wN+PlQ`gIuCYxnxTWg8kNGNnoyKccY?yMIyg)>V&WZ*;5 zg^1!Sf*|xEO6b94vA5_YqF!QG7LtXa9(wT2sHckP`@Cf0nR9;sIsb3weBYTfAC7)$ z&V81XV`JDJ{|xlJ$(zn?vYcqg=|dJ{VQ#Q+mcheHObuHMyP;lH!y2juH5*k!6{y*$ zR#bs%L$#vXQEjLWL+N6*4w$qwyW69jQY|+Ns)FOY7lOi@Bl_7Wf5Pu@&f*G;Ya8K) zIOnoF&0_31j-|%gD4Wng*IbGg&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H`#F-I}XGcQvHB!e`N4b$xHv9nQGJUxxL~ z`yZMgMjlC;`>^glyhO3qRszY^*{;XlpzhuFRpr<IZxzkkrF*+(`;4OVXB__9$5Vat zNA%F1Z0JxXbVv(z>!EHf(4z->7Hb<n=hA^zs1?2)YK3oyS^;1vzC7zFI_sfbdgx#_ z)SC(QYN38T)UO2w^uWMkZ9{50y)n>2+*^q|9H<0*;e2?GAHx6G-a`lRlwCtTxYuzX zZNq;%5~y$C4F4KJuP%J&yicQc9Ix12TS~A@x@C?Xk0=rNjgpU%ytLr&D;iM~epWGx zh87OHA0y<%n>`yt1~+ySlO6)S1O^BU5*Q+I5|4X==m&h+Q{BZ{%2RK_%d?cPh6=j{ zTE$AJ<}Glsl~B8o_Pj!)W?bca(?fWaqbH<9o^y0$VnW`IKlDXVY~c^zBedx>IY1SG z2!T-oQ34XcvmXHl!?ZkxwVHYq!++K6LMm?YC+p7=n|BD1_G~mR<A+r~MV17>$A1)^ v!gYb`fZqfH_9@Vk{~ZdA@GpTo?E?taFH!5`)#m5MlNZaMpEThwYCHb}4@xu! diff --git a/tests/__pycache__/processes.cpython-311.pyc b/tests/__pycache__/processes.cpython-311.pyc index 92b1fcdeb833fcab2d01c5aee9cac2ce7d97928b..4f4c7f10e1ab4079c040f28cc6c0a605611825e8 100644 GIT binary patch delta 4316 zcmd5<du&tJ8NcWHb)EQ?#Bt(09EUs_6XLwd0?xw;(83_)*#`|Z#&*DNn!vpmLYX7e zsZ&$R+H{AttZKJZq%;g#oF$p42GXjkYqf5g9bJjY6QciY5}P)KmHtyr+rICbICgkQ z{clIUzweyy{LZ=O-1B|k`F!OZ`OzFPe4y87F;F)BXYIhhoYRK4HCY;LL;3o*^jDge z2pdoblmRZFwI<bo4{Hr5mw5xMU-^=9Z<gQaSA)z3sR5}2$$`{^)PgjC%mQfynGMne zQU@{zq&^oaxll2H%=4>uF%HvAE%!G<KXX~wcUaocRY4TAysC&5(?oHBa#S(OhS{(p ztQ=5mVD^=as=}%Xm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;TA#6G3Kt`^u8SgFFw5UgA*rc?M_mCyaSW@76k zJyEKxFIU&&wc1o@3qc$D%aWYZIJsh?PRX;Wc{T-BsIVdw{RLeaw;`xRtFklWcjHGd zwG-Gwz=?KdH-YWwTJ{cOB@Q&#Nckl0LfqQIlse*;6R0IX##ACxBsHMMwcCIjU08b@ z)CV(i?r{1YB;H7%2|e796F*-OQE5Oqg#x>i<Xg~7g*$*8yi$0G2FFqI=C8qN^uy+_ zzz%e?s0R!NR~EMdfP#lhir8404)ldBE8a_F^aMBp+tDLiA9oSEatDK4t(M^NiU5PZ zXg6AukZo&RK6!s<_t8eY0|fdA93jw8;243o2%JVIx2~jrq0so&%EVNy{UNm&wgg|^ z)&<xK!mUJ8RY|~(?p2i-t8pNQj=YIdGfJtJ!RP2)^(Alwy^~s+89CJgOmXCZaN_Le zqf_dA-RX06bbFjqZy&PNbc0*yqnbC<2Z;7?qyd42wbD^^lubnKwL8I=!C<YQw#FQE z2dRi0&<Wx-AV+-`IEm!?c5o-C)B}+BE{VTKfE<~0nE?5&Njw1yfwNHvqJLgI2F?bL zZNH$!6O`QeiN1;CL;{Uyy0Hv2AVbq>a6fpdX%}O<g5wYFVsPXz(kS}7WjFnZLc3eL zR$V0(;{;-QjgT0DZ_tC*W-x*(c8#%-1&pAdccp`yDDIW-H#uk^JfxP!q5NMXnco-Y KJ2WV>&HXRN>vi$~ diff --git a/tests/__pycache__/utils.cpython-311.pyc b/tests/__pycache__/utils.cpython-311.pyc index 722fd5830e2c3aa3ab7c2903a319ed97db0bfa4b..5c85fd88cb170e68dd44f2a2701a756976989410 100644 GIT binary patch delta 2663 zcmc(he{2)y8OQzJ5BnVKoP!<5Hc2?rFzn!@A-@BZ{AemQg+eJU+R)mo<GX-OV#9lv zprAx9Ql%P*)M#(mvKCsaV<p{6M|Z1~YW;z_{lTQQ#o0;8ELED+X`QA@Gur;zKim79 z6K7=X&uOpi&-=d5``q)q?|b)s&wsp(?!AsGZ@AqRHd>zfN7v}5P488H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_%aSD zs}@UAf>`ArU4gBG4^v*4;X4cK3fQ*UAz6uO%+QuZtgJ+;$gvWOIHi&l#Xu5?F<>C6 z;+)3jC0lixu+mAoB9ROc-OVtQOySQUR+1(5%s+ku$rk4<Vr)&Y=kRT5CYgV;z1Nwv z#LhuENZ3YhAGC5;-Z4Y6CQ&6qgUWzHm|A!S2!CFf3jAvE6Fpqvj?z8)@($5H%|{dq z*iCdV+P#P{!iMl63K0P|T;_r6e6#GXu1M3XLcRn2sGylH2h~WJ4%+oGm3YOJ<04G* zuZ}l5nBnV{X#m;mm9rH3*-z*G8iM6rh#mw*3?i-}DiMbe`w*^O91w<jixJmT)>Ku) zA6M1mZDrZt?Ne1*X1}US;SRUgtODF%TPJg^H${PF2!(^abPPqB5ED#a>wtUASsQ{; zzEpbzV4S^km%}K7IxleEQWt`faV#}arLSL6Be7XcWA%){?o~(8F~>fiIu7eRuYN^m zWawFBFB|f`C_rx`W)ab8|5b>Od<jD_8MKxKv~;D{A0`Ts17X@D6JNwfS6F4E8=mn< zW19{Z*xS?R;WaO6It-SsxmjF0Zqd^KYxfk}umwBNHQeG)Qh?eI*u2LLAJ`|)IrDHV zXOTIZ9Uam3`Y~kzAqi;4aA!#IN1`h9KDv)0@V}>zFu@X^x?kz;mSyq1N#RvNpf2`k zBf_MJWxm-w4KTvn&x%QpunBJ-Z16SjC8!tzDA-Q;Kc_D2L?b``jSuPBiI%G0pndfU diff --git a/tests/__pycache__/versioned_attributes.cpython-311.pyc b/tests/__pycache__/versioned_attributes.cpython-311.pyc index 2e15b713e875b1326456eac2f8e06abecf708c73..7a33722119492d1373fd69099c33e3a4370e313e 100644 GIT binary patch delta 2321 zcmbVNS!@$W7@qO&+Uxtk*V;+!#1@G$0jd;eLP{_s;R*rbq!s2chTVjq9I##xqJg9> zQqzkjnzqoYsv;g*Bp#Y7t<<;jNG00Z?MjU-RiaXbTB#3?$^+ts{<D@z97-M-d%v0e z|9|JdzS;e0&#yhUFRfM+f^qxdrv9LB+U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^ggwXnJH|cqBd2zwhXP=AhK7!=MYNr^Yn(yrEg)p<p8NB=t|bcNNsCtH$xE zlhmz`f)Q+J`>?e@<RX#tL|&8RrTT)jrzq{2=ZYk-=55Lu#YD$SqVsBO(~Nz+w-5y= z24naljMgP+SKtcY4CxT>*wHb^!AHc$n-sIc!P}uE{KNUU3_53qmr0EmqX{&F*^rh{ zvWj@O6vR9n3;W?)-pA5kkoLlHj|Z+x!v9Z16s%Y#Oojkg!b!fQ60C>o+SyUmx+$z$ zw!79v2RBU2ouDuzTeTP)NDRUZdf?&6X?ycdM`2Tt;`-P{^?Azbhp5D}Xv2bR!n?Nj zg-b$qyg))l63UYhtVb@#V~f6=y+D#hlFXCjuf%yz*a~q%r1n&8Y*AkfeSBhRun_Mk z#ybk6vq(Dg<uCNqNjO{9;A<%YS&8<`1oS61!Gh$+rGB?zWY}nB+eZ7&4qnNaK9vV; zOBX0ewY8Mw6-y<30G;;Fm@+tLg-w?arm9@<bJXo1<%BsK72XRjUKD6(({r?qGv*mC z12?07ONPtfa|E8MmtiyNGZ}t(t=_+Du5){CIAr+C2@zs*%A?#)2>cLsZ>#u7Lswr( zMJ88CN{!tTZ9fAh=8!DxlJFpN_b{+B=wmPdpEV5N!*H|Vh`qf+S9l>-bw;N#`r{>C zA0XHLB&0s^l9)9vX9}dTNE-8`ajm9#$y=1WR^;xh`{`}+_hWjUD8h}{@0dWL(dS^- zRXf7q8F)1Ao9JhYv%if#&BMGMWf)<^OB8O;(gU~kS>ampT+0T>^SvABK_FK1T^pzp zT3|gMhQH!=xD&UVhhz^NOlY_lt|bESOCo4LMb}|P=t1~5@h0ctW<_|fdAuWuyEo9i QkZs*$-dp#fG&fE2AN)djA^-pY diff --git a/tests/conditions.py b/tests/conditions.py index faaeb87..45c3df7 100644 --- a/tests/conditions.py +++ b/tests/conditions.py @@ -25,42 +25,22 @@ class TestsWithDB(TestCaseWithDB): """Tests requiring DB, but not server setup.""" checked_class = Condition - def versioned_condition(self) -> Condition: - """Create Condition with some VersionedAttribute values.""" - c = Condition(None) - c.title.set('title1') - c.title.set('title2') - c.description.set('desc1') - c.description.set('desc2') - return c - def test_Condition_saving_and_caching(self) -> None: """Test .save/.save_core.""" kwargs = {'id_': 1, 'is_active': False} self.check_saving_and_caching(**kwargs) # check .id_ set if None, and versioned attributes too - c = self.versioned_condition() + c = Condition(None) c.save(self.db_conn) self.assertEqual(c.id_, 2) - self.assertEqual(sorted(c.title.history.values()), - ['title1', 'title2']) - self.assertEqual(sorted(c.description.history.values()), - ['desc1', 'desc2']) + self.check_saving_of_versioned('title', str) + self.check_saving_of_versioned('description', str) def test_Condition_from_table_row(self) -> None: """Test .from_table_row() properly reads in class from DB""" self.check_from_table_row() - c = self.versioned_condition() - c.save(self.db_conn) - assert isinstance(c.id_, int) - for row in self.db_conn.row_where(Condition.table_name, 'id', c.id_): - retrieved = Condition.from_table_row(self.db_conn, row) - # pylint: disable=no-member - self.assertEqual(sorted(retrieved.title.history.values()), - ['title1', 'title2']) - # pylint: disable=no-member - self.assertEqual(sorted(retrieved.description.history.values()), - ['desc1', 'desc2']) + self.check_versioned_from_table_row('title', str) + self.check_versioned_from_table_row('description', str) def test_Condition_by_id(self) -> None: """Test .by_id(), including creation.""" diff --git a/tests/processes.py b/tests/processes.py index 8616008..9e769c1 100644 --- a/tests/processes.py +++ b/tests/processes.py @@ -42,34 +42,58 @@ class TestsWithDB(TestCaseWithDB): p.save(self.db_conn) return p1, p2, p3 - def test_Process_saving_and_caching(self) -> None: - """Test .save/.save_core.""" - kwargs = {'id_': 1} - self.check_saving_and_caching(**kwargs) + def p_of_conditions(self) -> tuple[Process, list[Condition], + list[Condition], list[Condition]]: + """Return Process and its three Condition sets.""" p = Process(None) - p.title.set('t1') - p.title.set('t2') - p.description.set('d1') - p.description.set('d2') - p.effort.set(0.5) - p.effort.set(1.5) c1, c2, c3 = Condition(None), Condition(None), Condition(None) for c in [c1, c2, c3]: c.save(self.db_conn) assert isinstance(c1.id_, int) assert isinstance(c2.id_, int) assert isinstance(c3.id_, int) - p.set_conditions(self.db_conn, [c1.id_, c2.id_]) - p.set_enables(self.db_conn, [c2.id_, c3.id_]) - p.set_disables(self.db_conn, [c1.id_, c3.id_]) + set_1 = [c1, c2] + set_2 = [c2, c3] + set_3 = [c1, c3] + p.set_conditions(self.db_conn, [c.id_ for c in set_1 + if isinstance(c.id_, int)]) + p.set_enables(self.db_conn, [c.id_ for c in set_2 + if isinstance(c.id_, int)]) + p.set_disables(self.db_conn, [c.id_ for c in set_3 + if isinstance(c.id_, int)]) p.save(self.db_conn) + return p, set_1, set_2, set_3 + + def test_Process_saving_and_caching(self) -> None: + """Test .save/.save_core.""" + kwargs = {'id_': 1} + self.check_saving_and_caching(**kwargs) + self.check_saving_of_versioned('title', str) + self.check_saving_of_versioned('description', str) + self.check_saving_of_versioned('effort', float) + p, set1, set2, set3 = self.p_of_conditions() + p.uncache() r = Process.by_id(self.db_conn, p.id_) - self.assertEqual(sorted(r.title.history.values()), ['t1', 't2']) - self.assertEqual(sorted(r.description.history.values()), ['d1', 'd2']) - self.assertEqual(sorted(r.effort.history.values()), [0.5, 1.5]) - self.assertEqual(sorted(r.conditions), sorted([c1, c2])) - self.assertEqual(sorted(r.enables), sorted([c2, c3])) - self.assertEqual(sorted(r.disables), sorted([c1, c3])) + self.assertEqual(sorted(r.conditions), sorted(set1)) + self.assertEqual(sorted(r.enables), sorted(set2)) + self.assertEqual(sorted(r.disables), sorted(set3)) + + def test_Process_from_table_row(self) -> None: + """Test .from_table_row() properly reads in class from DB""" + self.check_from_table_row() + self.check_versioned_from_table_row('title', str) + self.check_versioned_from_table_row('description', str) + self.check_versioned_from_table_row('effort', float) + p, set1, set2, set3 = self.p_of_conditions() + p.save(self.db_conn) + assert isinstance(p.id_, int) + for row in self.db_conn.row_where(self.checked_class.table_name, + 'id', p.id_): + # pylint: disable=no-member + r = Process.from_table_row(self.db_conn, row) + self.assertEqual(sorted(r.conditions), sorted(set1)) + self.assertEqual(sorted(r.enables), sorted(set2)) + self.assertEqual(sorted(r.disables), sorted(set3)) def test_Process_steps(self) -> None: """Test addition, nesting, and non-recursion of ProcessSteps""" diff --git a/tests/utils.py b/tests/utils.py index fbe739d..bb37270 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -80,6 +80,19 @@ class TestCaseWithDB(TestCase): for key, value in kwargs.items(): self.assertEqual(getattr(obj, key), value) + def check_saving_of_versioned(self, attr_name: str, type_: type) -> None: + """Test owner's versioned attributes.""" + owner = self.checked_class(None) + vals: list[Any] = ['t1', 't2'] if type_ == str else [0.9, 1.1] + attr = getattr(owner, attr_name) + attr.set(vals[0]) + attr.set(vals[1]) + owner.save(self.db_conn) + owner.uncache() + retrieved = owner.__class__.by_id(self.db_conn, owner.id_) + attr = getattr(retrieved, attr_name) + self.assertEqual(sorted(attr.history.values()), vals) + def check_by_id(self) -> None: """Test .by_id(), including creation.""" # check failure if not yet saved @@ -109,6 +122,20 @@ class TestCaseWithDB(TestCase): self.assertEqual(obj, retrieved) self.assertEqual({obj.id_: obj}, self.checked_class.get_cache()) + def check_versioned_from_table_row(self, attr_name: str, + type_: type) -> None: + """Test .from_table_row() reads versioned attributes from DB.""" + owner = self.checked_class(None) + vals: list[Any] = ['t1', 't2'] if type_ == str else [0.9, 1.1] + attr = getattr(owner, attr_name) + attr.set(vals[0]) + attr.set(vals[1]) + owner.save(self.db_conn) + for row in self.db_conn.row_where(owner.table_name, 'id', owner.id_): + retrieved = owner.__class__.from_table_row(self.db_conn, row) + attr = getattr(retrieved, attr_name) + self.assertEqual(sorted(attr.history.values()), vals) + def check_all(self) -> tuple[Any, Any, Any]: """Test .all().""" # pylint: disable=not-callable diff --git a/tests/versioned_attributes.py b/tests/versioned_attributes.py index 69c31fe..a75fc3c 100644 --- a/tests/versioned_attributes.py +++ b/tests/versioned_attributes.py @@ -6,7 +6,7 @@ from tests.utils import TestCaseWithDB from plomtask.versioned_attributes import VersionedAttribute, TIMESTAMP_FMT from plomtask.db import BaseModel -SQL_TEST_TABLE = ''' +SQL_TEST_TABLE_STR = ''' CREATE TABLE versioned_tests ( parent INTEGER NOT NULL, timestamp TEXT NOT NULL, @@ -14,6 +14,14 @@ CREATE TABLE versioned_tests ( PRIMARY KEY (parent, timestamp) ); ''' +SQL_TEST_TABLE_FLOAT = ''' +CREATE TABLE versioned_tests ( + parent INTEGER NOT NULL, + timestamp TEXT NOT NULL, + value REAL NOT NULL, + PRIMARY KEY (parent, timestamp) +); +''' class TestParentType(BaseModel[int]): @@ -81,20 +89,22 @@ class TestsSansDB(TestCase): self.assertEqual(attr.at(timestamp_after_c), 'C') -class TestsWithDB(TestCaseWithDB): +class TestsWithDBStr(TestCaseWithDB): """Module tests requiring DB setup.""" + default_vals: list[str | float] = ['A', 'B', 'C'] + init_sql = SQL_TEST_TABLE_STR def setUp(self) -> None: super().setUp() - self.db_conn.exec(SQL_TEST_TABLE) + self.db_conn.exec(self.init_sql) self.test_parent = TestParentType(1) self.attr = VersionedAttribute(self.test_parent, - 'versioned_tests', 'A') + 'versioned_tests', self.default_vals[0]) def test_VersionedAttribute_save(self) -> None: """Test .save() to write to DB.""" # check mere .set() calls do not by themselves reflect in the DB - self.attr.set('B') + self.attr.set(self.default_vals[1]) self.assertEqual([], self.db_conn.row_where('versioned_tests', 'parent', 1)) @@ -103,25 +113,32 @@ class TestsWithDB(TestCaseWithDB): vals_found = [] for row in self.db_conn.row_where('versioned_tests', 'parent', 1): vals_found += [row[2]] - self.assertEqual(['B'], vals_found) + self.assertEqual([self.default_vals[1]], vals_found) # check .save() also updates history in DB - self.attr.set('C') + self.attr.set(self.default_vals[2]) self.attr.save(self.db_conn) vals_found = [] for row in self.db_conn.row_where('versioned_tests', 'parent', 1): vals_found += [row[2]] - self.assertEqual(['B', 'C'], sorted(vals_found)) + self.assertEqual([self.default_vals[1], self.default_vals[2]], + sorted(vals_found)) def test_VersionedAttribute_history_from_row(self) -> None: """"Test .history_from_row() properly interprets DB rows.""" - self.attr.set('B') - self.attr.set('C') + self.attr.set(self.default_vals[1]) + self.attr.set(self.default_vals[2]) self.attr.save(self.db_conn) - loaded_attr = VersionedAttribute(self.test_parent, - 'versioned_tests', 'A') + loaded_attr = VersionedAttribute(self.test_parent, 'versioned_tests', + self.default_vals[0]) for row in self.db_conn.row_where('versioned_tests', 'parent', 1): loaded_attr.history_from_row(row) for timestamp, value in self.attr.history.items(): self.assertEqual(value, loaded_attr.history[timestamp]) self.assertEqual(len(self.attr.history.keys()), len(loaded_attr.history.keys())) + + +class TestsWithDBFloat(TestsWithDBStr): + """Module tests requiring DB setup.""" + default_vals: list[str | float] = [0.9, 1.1, 2] + init_sql = SQL_TEST_TABLE_FLOAT -- 2.30.2