def test_modify_node(): node = ast_call("S3Downloader.download(session=sess)") modifier = renamed_params.S3SessionRenamer() modifier.modify_node(node) expected = "S3Downloader.download(sagemaker_session=sess)" assert expected == pasta.dump(node)
def test_node_should_be_modified_no_session(): modifier = renamed_params.S3SessionRenamer() for func in FUNCTIONS: for namespace in NAMESPACES: call = ast_call("{}{}()".format(namespace, func)) assert not modifier.node_should_be_modified(call)
def test_node_should_be_modified_random_function_call(): modifier = renamed_params.S3SessionRenamer() generic_function_calls = ( "download()", "list()", "read_file()", "upload()", ) for call in generic_function_calls: assert not modifier.node_should_be_modified(ast_call(call))