piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit b63d2d271bc5fca3626053914efb5678d4f7a4e2
parent 8d16035dc11345e3675d7524f64ccb899ca7fafa
Author: lash <dev@holbrook.no>
Date:   Tue, 15 Nov 2022 05:23:33 +0000

Serialize and deserialize assignments in issues

Diffstat:
Mpiknik/error.py | 4++++
Mpiknik/identity.py | 12++++++++----
Mpiknik/issue.py | 34++++++++++++++++++++++++++++++++--
Atests/beastman.asc | 41+++++++++++++++++++++++++++++++++++++++++
Atests/merman.asc | 41+++++++++++++++++++++++++++++++++++++++++
Atests/merman.priv.asc | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtests/test_assign.py | 21++++++++++++++++-----
Mtests/test_issue.py | 25++++++++++++++++++++++---
8 files changed, 247 insertions(+), 14 deletions(-)

diff --git a/piknik/error.py b/piknik/error.py @@ -1,2 +1,6 @@ class DeadIssue(Exception): pass + + +class AlreadyAssignedError(Exception): + pass diff --git a/piknik/identity.py b/piknik/identity.py @@ -1,14 +1,18 @@ import hashlib + class Identity: def __init__(self, fingerprint): - self.fp = bytes.fromhex(fingerprint) - + self.__id = bytes.fromhex(fingerprint) + + + def id(self): + return self.__id.hex() + def uri(self): h = hashlib.sha256() - h.update(self.fp) + h.update(self.id) z = h.digest() return 'sha256:' + z.hex() - diff --git a/piknik/issue.py b/piknik/issue.py @@ -1,5 +1,10 @@ +# standard imports import uuid import json +import datetime + +# local imports +from piknik.identity import Identity class Issue: @@ -9,20 +14,45 @@ class Issue: issue_id = str(uuid.uuid4()) self.id = issue_id self.title = title + self.assigned = [] + self.assigned_time = [] @staticmethod def from_str(s): r = json.loads(s) o = Issue(title=r['title'], issue_id=r['id']) + for k in r['assigned'].keys(): + p = Identity(k) + o.assigned.append(p) + t = datetime.datetime.utcfromtimestamp(r['assigned'][k]) + o.assigned_time.append(t) return o + def assign(self, identity, t=None): + if identity in self.assigned: + raise AlreadyAssignedError(identity) + if t == None: + t = datetime.datetime.utcnow() + self.assigned.append(identity) + self.assigned_time.append(t) + + + def get_assigned(self): + return list(zip(self.assigned, self.assigned_time)) + + def __str__(self): - return json.dumps({ + o = { 'id': str(self.id), 'title': self.title, - }) + 'assigned': {}, + } + for v in self.get_assigned(): + o['assigned'][v[0].id()] = v[1].timestamp() + + return json.dumps(o) def __eq__(self, o): diff --git a/tests/beastman.asc b/tests/beastman.asc @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBF+hSRoBDADavYeIu+mdyXJkyh5yTUsWhXIRT8KM9xhYXUHvp6Q72auVi9sq +yezIvRZy4SrAKYd0uTvSLvjcWfbVZAri6++W+sSl6/1qP0OKHIty2/iqs+brABT9 +eJt/vm2DWJEv6a4xB+/qFCGN2HCRgXH/tdDpRaQSJuoVLvEnCuHP2UcvgpMDiw7k +95bvXf6anPu0zlGYZXo05ADIQR8C/o5rCVaTR/mjzGeAijKjYFLmoh4QE76LPjn4 +YbwZALpe584jHtVWX75mmzFkq0Or8Bd8CyTF8tHBkyof0Nvmk8zOsvVs9XXoDCha +qEAZ3YcgyQ4MsQLldMYgoKo7n6fbzyseEAlOoWYTtOkCj4RvROSTiN+bovJGieZA +am79nFrnefkPp34CBhYAx4eQS2FYmQRLiYqlm7idXbX6f2bKec+DzDO2EvvTlDog +GO2XFfwQ/p55EUTUFQI2nZFm21NJ0j7yLDNiwY4l0l55d4s4aG9T388uRGP2OBku +AIsCjVAajajF61kAEQEAAbQiQmVhc3QgTWFuIDxiZWFzdG1hbkBncmV5c2t1bGwu +Y29tPokB1AQTAQgAPhYhBPZF4EfuW8TigkyU20Lckc+oq6ArBQJfoUkaAhsDBQkD +wmcABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEELckc+oq6ArbmEL/1UXV96S +PQgqes4lFRwr8K/hEGjCXrRX3XDbsCmyg/ZrAQmIWFjupGKO2QDc0qtPe2R7tpOc +LfIAnxIU6a8gAL3iKNvsi/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7Ptu/4T9 +TX/tF3LkwfCvhYXqhlGkgGWC/cZdd4gUf1sV0OGDI8qCH5PPbgkEv7tiNS1YZ78b ++maY0rVhrMH87GvCIYWlMLKTXOHESSEy7se7cuAPnvUr7hNRSlo8KoR6gEGDo7dP +b0MfUDGlakQ8ZeU6tEMdiBXOISkt1Q1qECMXndq41a/Jr5VzapnAzg0W3rTwst/s +nnIgDa9uy9/r6BWik8TfCFcRIpejTwHaELV/c+v39OC3qgi/L390BxMxqXFHLJzj +YTbBfmTLMOV+Fj2Spo019oYxkk7mD/+AHsF22sB+j8uFa1qvL9h8A61tucxiR/4c +4MA9ki1oiMxmeAEzRzSbvxigJ60BATy4EUrppeaG3cFkY87CDJmkrlBPoKViy3Y3 +1xre09QR+d12i0rJKYIST8la27n/SUWXvlbMe6VzuJQ0YmadR99VnIfXYKMFaxO2 +qiZscOR0QoWhxq+qlVwIJspu1bkZmG5kLrk= +=8AJB +-----END PGP PUBLIC KEY BLOCK----- diff --git a/tests/merman.asc b/tests/merman.asc @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBF+hSOgBDACpkPQEjADjnQtjmAsdPYpx5N+OMJBYj1DAoIYsDtV6vbcBJQt9 +4Om3xl7RBhv9m2oLgzPsiRwjCEFRWyNSu0BUp5CFjcXfm0S4K2egx4erFnTnSSC9 +S6tmVNrVNEXvScE6sKAnmJ7JNX1ExJuEiWPbUDRWJ1hoI9+AR+8EONeJRLo/j0Np ++S4IFDn0PsxdT+SB0GY0z2cEgjvjoPr4lW9IAb8Ft9TDYp+mOzejn1Fg7CuIrlBR +SAv+sj7bVQw15dh1SpbwtS5xxubCa8ExEGI4ByXmeXdR0KZJ+EA5ksO0iSsQ/6ip +SOdSg+i0niOClFNm1P/OhbUsYAxCUfiX654FMn2zoxVBEjJ3e7l0pH7ktodaxEct +PofQLBA9LSDUIejqJsU0npw/DHDD2uvxG+/A6lgV9L8ETlvgp8RzeOCf2bHuiKYY +z87txvkF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J4YtIzQMG9 +HViaXTjGzP6JHbu2BQmUazGF1/ZKql4Q6kbsO3QMRsPudV6UJEcP8oudaSBuexPl +Y43cRsR2/I9Kff3CWFcVSFmfsQ6yHOm41okBvAQYAQgAJhYhBPP69mjoLvUSTVGH +uu8m9GgjQ/aSBQJfoUjoAhsMBQkDwmcAAAoJEO8m9GgjQ/aSIPcL/3jqL2A2SmC+ +s0BO4vMPEfCpa2gZ/vo1azzjUieZu5WhIxb5ik0V6T75EW5F0OeZj9qXI06gW+IM +8+C6ImUgaR3l47UjBiBPq+uKO9QuT/nOtbSs2dXoTNCLMQN7MlrdUBix+lnqZZGS +Dgh6n/uVyAYw8Sh4c3/3thHUiR7xzVKGxAKDT8LoVjhHshTzYuQq8MqlfvwVI4eE +SLaryQ+Y+j5+VLDzSLgPAnnIqF/ui2JQjefJxm/VLoYNaPAGdqoz/u/R0Tmz94bZ +UfLjgQaDoUpnxYywK2JGlf3mPZ3PNWjxJzuQTF5Ge5bz/TylnRYIyBT7KD7oaKHO +62fhDbYPJ4f94iZN4B6nnTAeP34zFDlkUbX4AHudXU7bvxT5OUk9x9c2tj7xwxQH +aEhq2+JsYW0EVw27RLhbymnBfLjVVUktNF0nQGvU2TEocw4pr2ZkDHQkSnlbNa4k +ujlL7VzbpnEgyOmi5er9GaIuVSVADovBu+pz/Ov1y/3jUe8hZ/KleQ== +=sth5 +-----END PGP PRIVATE KEY BLOCK----- diff --git a/tests/test_assign.py b/tests/test_assign.py @@ -3,17 +3,20 @@ import unittest import logging import json -logging.basicConfig(level=logging.DEBUG) -logg = logging.getLogger() - +# local imports from piknik import Issue from piknik.identity import Identity +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + class TestAssign(unittest.TestCase): def setUp(self): self.alice = 'F3FAF668E82EF5124D5187BAEF26F4682343F692' + self.bob = 'F645E047EE5BC4E2824C94DB42DC91CFA8ABA02B' + def test_identity_pointer(self): check = "sha256:65ea9b0609341322903823660bf45326f473d903ee7d327dff442f46d68eacd9" @@ -22,9 +25,17 @@ class TestAssign(unittest.TestCase): self.assertEqual(r, check) - def test_basic(self): + def test_identity_load(self): o = Issue('foo') - #p = Identity() + alice = Identity(self.alice) + o.assign(alice) + bob = Identity(self.bob) + o.assign(bob) + r = o.get_assigned() + self.assertEqual(len(r), 2) + self.assertEqual(r[0][0], alice) + self.assertEqual(r[1][0], bob) + self.assertGreater(r[1][1], r[0][1]) if __name__ == '__main__': diff --git a/tests/test_issue.py b/tests/test_issue.py @@ -3,11 +3,13 @@ import unittest import logging import json +# local imports +from piknik import Issue +from piknik.identity import Identity + logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() -from piknik import Issue - class TestIssue(unittest.TestCase): @@ -18,12 +20,29 @@ class TestIssue(unittest.TestCase): self.assertEqual(o.title, r['title']) - def test_from_str(self): + def test_basic_from_str(self): + o = Issue('foo') + v = str(o) + r = Issue.from_str(v) + self.assertTrue(o == r) + + + + def test_assigned_from_str(self): o = Issue('foo') + alice_fp = 'F3FAF668E82EF5124D5187BAEF26F4682343F692' + alice = Identity(alice_fp) + bob_fp = 'F645E047EE5BC4E2824C94DB42DC91CFA8ABA02B' + bob = Identity(bob_fp) + o.assign(alice) + o.assign(bob) v = str(o) r = Issue.from_str(v) self.assertTrue(o == r) + check = r.get_assigned() + self.assertEqual(len(check), 2) + if __name__ == '__main__': unittest.main()