Created
April 5, 2017 09:32
-
-
Save Pentusha/2039485a583781e7dd30f99b5a753e2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyrfc import Connection | |
from pprint import pprint | |
connection_info = { | |
'ashost': '...', | |
'client': '...', | |
'lang': '...', | |
'user': '...', | |
'passwd': '...', | |
'sysid': '...', | |
'sysnr': '...', | |
} | |
function_name = u'ZHHDEMO_STRUCT_MOD' | |
table_name = u'ZHHTT_COL2' | |
struct_name = u'ZHHS_COL2' | |
def function_call(): | |
with Connection(**connection_info) as con: | |
return con.call(function_name) | |
def get_cache(): | |
with Connection(**connection_info) as con: | |
table_cached = con.type_desc_get(table_name) | |
struct_cached = con.type_desc_get(struct_name) | |
return { | |
table_name: vars(table_cached), | |
struct_name: vars(struct_cached), | |
} | |
def invalidate(): | |
with Connection(**connection_info) as con: | |
con.func_desc_remove(connection_info['sysid'], function_name) | |
con.type_desc_remove(connection_info['sysid'], table_name) | |
con.type_desc_remove(connection_info['sysid'], struct_name) | |
if __name__ == '__main__': | |
c1 = get_cache() | |
function_call() | |
c2 = get_cache() | |
invalidate() | |
c3 = get_cache() | |
pprint(c1) | |
assert not c1 == c2 == c3, 'The cache has not changed' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{u'ZHHS_COL2': {'fields': [{'decimals': 0, | |
'field_type': u'RFCTYPE_CHAR', | |
'name': u'COL1', | |
'nuc_length': 255, | |
'nuc_offset': 0, | |
'type_description': None, | |
'uc_length': 510, | |
'uc_offset': 0}, | |
{'decimals': 0, | |
'field_type': u'RFCTYPE_CHAR', | |
'name': u'COL2', | |
'nuc_length': 255, | |
'nuc_offset': 255, | |
'type_description': None, | |
'uc_length': 510, | |
'uc_offset': 510}], | |
'name': u'ZHHS_COL2', | |
'nuc_length': 510, | |
'uc_length': 1020}, | |
u'ZHHTT_COL2': {'fields': [{'decimals': 0, | |
'field_type': u'RFCTYPE_CHAR', | |
'name': u'COL1', | |
'nuc_length': 255, | |
'nuc_offset': 0, | |
'type_description': None, | |
'uc_length': 510, | |
'uc_offset': 0}, | |
{'decimals': 0, | |
'field_type': u'RFCTYPE_CHAR', | |
'name': u'COL2', | |
'nuc_length': 255, | |
'nuc_offset': 255, | |
'type_description': None, | |
'uc_length': 510, | |
'uc_offset': 510}], | |
'name': u'ZHHTT_COL2', | |
'nuc_length': 510, | |
'uc_length': 1020}} | |
Traceback (most recent call last): | |
File "tests/issue_40_not_my.py", line 49, in <module> | |
assert not c1 == c2 == c3, 'The cache has not changed' | |
AssertionError: The cache has not changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment