Skip to content

Commit

Permalink
Unit tests in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ianco committed Sep 6, 2018
1 parent d6930be commit 322b313
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
46 changes: 46 additions & 0 deletions data-pipeline/bcreg/tests/bcreg_test_dev_corps.py
@@ -0,0 +1,46 @@

import time

from bcreg.bcregistries import BCRegistries, system_type
from bcreg.eventprocessor import EventProcessor
from bcreg.tests.sample_corps import sample_test_corps


def test_dev_corp_sql():
specific_corps = [
#'0574972',
'0657791'
]

with BCRegistries(True) as bc_registries:
for corp in specific_corps:
#print('=========================')
print('===== ', corp)
bc_registries.cache_bcreg_corp_tables([corp], True)
sqls = bc_registries.generated_sqls
fake_corp_num = bc_registries.add_generated_corp_num(corp)
print('=============>>> ', fake_corp_num)
#print('=========================')
#print('sqls:')
#for sql in sqls:
# print('"""' + sql.replace(' values ', '\nvalues\n') + '""",')
#print('=========================')

with BCRegistries(True) as cached_bc_reg:
cached_bc_reg.cache_bcreg_code_tables()
cached_bc_reg.insert_cache_sqls(sqls)

# try running with dummy event id zero
corp_info = cached_bc_reg.get_bc_reg_corp_info(fake_corp_num, 0)
#print('-------------------------')
#print('corp_info:')
#print(corp_info)
#print('-------------------------')

with EventProcessor() as event_processor:
corp_creds = event_processor.generate_credentials(system_type, 0, 0, fake_corp_num, corp_info)
#print('-------------------------')
#print('corp_creds:')
#print(corp_creds)
#print('-------------------------')

55 changes: 55 additions & 0 deletions data-pipeline/bcreg/tests/bcreg_test_prod_corps.py
@@ -0,0 +1,55 @@

import time

from bcreg.bcregistries import BCRegistries, system_type
from bcreg.eventprocessor import EventProcessor
from bcreg.tests.sample_corps import sample_test_corps


def test_dev_corp_sql():
specific_corps = [
'1159443',
]

# try caching everything
#with BCRegistries(True) as bc_registries:
# bc_registries.cache_bcreg_corps(specific_corps)

#def test_dev_corp_sql():
# specific_corps = [
# 'C1033288','C1043095'
# ]

# go one-by-one
with BCRegistries(True) as bc_registries:
for corp in specific_corps:
#print('=========================')
print('===== ', corp)
bc_registries.cache_bcreg_corp_tables([corp], True)
sqls = bc_registries.generated_sqls
fake_corp_num = bc_registries.add_generated_corp_num(corp)
print('=============>>> ', fake_corp_num)
#print('=========================')
#print('sqls:')
#for sql in sqls:
# print('"""' + sql.replace(' values ', '\nvalues\n') + '""",')
#print('=========================')

with BCRegistries(True) as cached_bc_reg:
cached_bc_reg.cache_bcreg_code_tables()
cached_bc_reg.insert_cache_sqls(sqls)

# try running with dummy event id zero
corp_info = cached_bc_reg.get_bc_reg_corp_info(fake_corp_num, 0)
#print('-------------------------')
#print('corp_info:')
#print(corp_info)
#print('-------------------------')

with EventProcessor() as event_processor:
corp_creds = event_processor.generate_credentials(system_type, 0, 0, fake_corp_num, corp_info)
#print('-------------------------')
#print('corp_creds:')
#print(corp_creds)
#print('-------------------------')

Binary file modified doc/BCReg-DBA-Data-Model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/BCReg-Data-Model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/Event-Processor-Data-Model.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/Event-Processor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 322b313

Please sign in to comment.