cic-cli/tests/test_processor.py

54 lines
1.1 KiB
Python

# standard imports
import unittest
import logging
import os
import json
# external imports
from hexathon import strip_0x
# local imports
from cic.processor import Processor
from cic.meta import Meta
# test imports
from tests.base_cic import (
TestCICBase,
test_data_dir,
)
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class MockExt:
def __init__(self, address):
self.address = address
def process(self):
return self.address
class TestCICProcessor(TestCICBase):
def test_processor(self):
fp = os.path.join(test_data_dir, 'proof')
m = Meta(fp)
m.load()
mock_ext = MockExt(self.token_address)
p = Processor(metadata=m, outputs_writer=self.outputs_writer, extensions=[mock_ext])
p.process()
meta_reference = m.reference(self.token_address)
fp = os.path.join(self.outputs_dir, meta_reference)
f = open(fp, 'r')
o = json.load(f)
f.close()
self.assertEqual(m.asdict(), o)
if __name__ == '__main__':
unittest.main()