forked from manusimidt/py-xbrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_local_instance.py
43 lines (33 loc) · 1.36 KB
/
test_local_instance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
This unittest tests the parsing of locally saved instance documents.
"""
import sys
import unittest
from xbrl.cache import HttpCache
from xbrl.instance import parse_ixbrl, parse_xbrl, XbrlInstance
import logging
# abs_file_path: str = str(os.path.dirname(os.path.abspath(inspect.getframeinfo(inspect.currentframe()).filename)))
class InstanceTest(unittest.TestCase):
"""
Unit test for taxonomy.test_parse_taxonomy()
"""
def test_parse_xbrl_document(self):
""" Integration test for instance.parse_xbrl_instance() """
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
cache_dir: str = './cache/'
cache: HttpCache = HttpCache(cache_dir)
instance_doc_url: str = './tests/data/example.xml'
inst: XbrlInstance = parse_xbrl(instance_doc_url, cache)
print(inst)
self.assertEqual(len(inst.facts), 1)
def test_parse_ixbrl_document(self):
""" Integration test for instance.parse_ixbrl_instance() """
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
cache_dir: str = './cache/'
cache: HttpCache = HttpCache(cache_dir)
instance_doc_url: str = './tests/data/example.html'
inst: XbrlInstance = parse_ixbrl(instance_doc_url, cache)
print(inst)
self.assertEqual(len(inst.facts), 3)
if __name__ == '__main__':
unittest.main()