asset.py (1048B)
1 import logging 2 import os 3 import unittest 4 5 import lxml.etree 6 7 from usawa.asset import Asset 8 9 10 logging.basicConfig(level=logging.DEBUG) 11 logg = logging.getLogger() 12 13 testdir = os.path.realpath(os.path.dirname(__file__)) 14 15 16 class TestAsset(unittest.TestCase): 17 18 def test_asset_file(self): 19 fp = os.path.join(testdir, 'test.xml') 20 asset = Asset.from_file(fp) 21 logg.debug('asset {}'.format(asset)) 22 23 24 def test_asset_export(self): 25 fp = os.path.join(testdir, 'test.xml') 26 asset = Asset.from_file(fp, slug='foo', description='barbarbar', extref='xyzzy') 27 tree = asset.to_tree() 28 logg.debug('asset {}'.format(lxml.etree.tostring(tree))) 29 30 31 def test_asset_import(self): 32 fp = os.path.join(testdir, 'test.xml') 33 asset = Asset.from_file(fp, slug='foo', description='barbarbar', extref='xyzzy') 34 tree = asset.to_tree() 35 36 s = lxml.etree.tostring(tree) 37 tree = lxml.etree.fromstring(s) 38 o = Asset.from_tree(tree) 39 40 41 if __name__ == '__main__': 42 unittest.main()