adesse

Signed testimonials for certifications.
Info | Log | Files | Refs

test_serialize.py (1287B)


      1 import unittest
      2 import datetime
      3 import hashlib
      4 
      5 from rdflib.term import URIRef
      6 
      7 from adesse import Serializer, Entity, Person, Org, Action, Cert, Event, Testimony, Attachment
      8 from adesse.ns import DF
      9 
     10 
     11 class TestSerialize(unittest.TestCase):
     12 
     13 
     14     def setUp(self):
     15         pass
     16 
     17 
     18     def test_serialize(self):
     19         z = Serializer()
     20         subj = Person("Melvin", "Ferd", "SV", common_name="Melvin B. Ferd")
     21         subj.set_url('http://rotten.com')
     22         obj = Action('foo', datetime.datetime.fromtimestamp(1758673250), datetime.datetime.fromtimestamp(1758679250))
     23         agent = Org("Toxic Mopping Inc.")
     24         agent.set_url('http://foo.xyz')
     25         crt = Event(subj, obj, agent)
     26         o = Cert('bundle in the jungle', crt)
     27         v = Testimony('testify', datetime.datetime.now(), crt, URIRef('did:deadbeef'))
     28         d = Attachment('some medium', 'foo baz bar', datetime.datetime.now(), 'image/png')
     29         h = hashlib.sha256()
     30         h.update(b'foo')
     31         d.set_sum(h.digest())
     32         v.add_claim(d)
     33 
     34         b = URIRef('http://internetofproduction.org')
     35         v.add_behalf(b)
     36         v.add_medium(DF.presence)
     37         v.add_medium(DF.realtime)
     38 
     39         o.add_testimony(v)
     40         o.apply(z)
     41         print(str(z))
     42 
     43 
     44 if __name__ == '__main__':
     45     unittest.main()