This commit is contained in:
2022-02-21 08:34:25 +03:00
parent d3f65798f1
commit fb3253ae55
28 changed files with 1529 additions and 316 deletions

View File

@@ -1,31 +1,55 @@
# standard imports
import unittest
import logging
import os
import unittest
# external imports
from hexathon import strip_0x
# local imports
from cic.meta import Meta
# external imports
from hexathon import strip_0x
# test imports
from tests.base_cic import (
TestCICBase,
test_data_dir,
)
from tests.base_cic import TestCICBase, test_data_dir
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class TestCICMeta(TestCICBase):
def test_meta(self):
fp = os.path.join(test_data_dir, 'proof')
fp = os.path.join(test_data_dir, "proof")
m = Meta(fp)
m.load()
self.assertEquals(
str(m),
"""name = Test
contact.phone = 0700-123456
country_code = KE
location = Kilifi
""",
)
def test_meta_with_initial_values(self):
fp = os.path.join(test_data_dir, "proof")
m = Meta(
fp,
name="TestName",
location="TestLocation",
country_code="TestCC",
contact={
"phone": "0723578455158",
},
)
self.assertEquals(
str(m),
"""name = TestName
contact.phone = 0723578455158
country_code = TestCC
location = TestLocation
""",
)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

View File

@@ -1,26 +1,39 @@
# standard imports
import logging
import os
import unittest
import logging
# local imports
from cic import Proof
from cic.attachment import Attachment
# test imports
from tests.base_cic import (
test_data_dir,
TestCICBase,
root_merged_hash,
)
from tests.base_cic import TestCICBase, root_merged_hash, test_data_dir
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class TestProof(TestCICBase):
def test_proof(self):
proof_path = os.path.join(test_data_dir, "proof")
attach = Attachment(proof_path, writer=self.outputs_writer)
attach.load()
c = Proof(path=proof_path, attachments=attach)
c.load()
self.assertEquals(
str(c),
"""description = foo bar baz
issuer = the man
namespace = ge
version = 0
proofs[0] = 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
proofs[1] = fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9
""",
)
def test_proof_serialize_merge(self):
proof_path = os.path.join(test_data_dir, 'proof')
proof_path = os.path.join(test_data_dir, "proof")
attach = Attachment(proof_path, writer=self.outputs_writer)
attach.load()
@@ -31,5 +44,5 @@ class TestProof(TestCICBase):
self.assertEqual(v, root_merged_hash)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

View File

@@ -1,7 +1,8 @@
{
"name": "",
"location": "",
"country_code": "",
"name": "Test",
"location": "Kilifi",
"country_code": "KE",
"contact": {
"phone": "0700-123456"
}
}