Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpClass(cls):
# print "Os cwd", os.getcwd()
# print "Config", config
## print config._sections.items()
cls.conn = pyrfc.Connection(**config._sections['connection'])
def test_no_connection_params(self):
try:
pyrfc.Connection()
except pyrfc.RFCError as ex:
assert ex.args[0] == "Connection parameters missing"
def test_config_parameter(self):
# rstrip test
conn = pyrfc.Connection(config={"rstrip": False}, **config_sections["coevi51"])
hello = u"Hällo SAP!" + u" " * 245
result = conn.call("STFC_CONNECTION", REQUTEXT=hello)
# Test with rstrip=False (input length=255 char)
assert result["ECHOTEXT"] == hello
result = conn.call("STFC_CONNECTION", REQUTEXT=hello.rstrip())
# Test with rstrip=False (input length=10 char)
assert result["ECHOTEXT"] == hello
conn.close()
# dtime test
conn = pyrfc.Connection(config={"dtime": True}, **config_sections["coevi51"])
dates = conn.call("BAPI_USER_GET_DETAIL", USERNAME="demo")["LASTMODIFIED"]
assert type(dates["MODDATE"]) is datetime.date
assert type(dates["MODTIME"]) is datetime.time
del conn
conn = pyrfc.Connection(**config_sections["coevi51"])
dates = conn.call("BAPI_USER_GET_DETAIL", USERNAME="demo")["LASTMODIFIED"]
def test_collect(self):
self.engine.get_user_connection(user, passwd)
poolsize_pre = self.engine._size
normal_conn = pyrfc.Connection(user=user, passwd=passwd, **params)
self.engine.collect(user, normal_conn)
self.assertEqual(poolsize_pre+1, self.engine._size)
def run(COUNT):
conn = Connection(**MME)
result = conn.call('STFC_PERFORMANCE', **{
'CHECKTAB': 'X', 'LGET0332': str(COUNT), 'LGET1000': str(COUNT)})
return result
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 main():
config = ConfigParser()
config.read("sapnwrfc.cfg")
params_connection = config._sections["connection"]
conn = Connection(**params_connection)
result = conn.call("STFC_STRUCTURE", IMPORTSTRUCT=imp)
pprint(result)
def invalidate():
with pyrfc.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)
# con.reset_server_context()