How to use rename_request method in locust

Best Python code snippet using locust

test_server_rename.py

Source:test_server_rename.py Github

copy

Full Screen

...4 run_request,5 test_dir,6 write_rpc_request,7)8def rename_request(new_name: str, file_path, ln: int, ch: int):9 return write_rpc_request(10 1,11 "textDocument/rename",12 {13 "newName": new_name,14 "textDocument": {"uri": str(file_path)},15 "position": {"line": ln, "character": ch},16 },17 )18def check_rename_response(response: dict, references: dict):19 # Loop over URI's if the change spans multiple files there will be more than 120 for uri, changes in response.items():21 refs = references[uri]22 # Loop over all the changes in the current URI, instances of object23 for c, r in zip(changes, refs):24 assert c["range"] == r["range"]25 assert c["newText"] == r["newText"]26def create(new_text: str, sln: int, sch: int, eln: int, ech: int):27 return {28 "range": {29 "start": {"line": sln, "character": sch},30 "end": {"line": eln, "character": ech},31 },32 "newText": new_text,33 }34def test_rename_var():35 """ "Test simple variable rename"""36 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})37 file_path = test_dir / "test_prog.f08"38 string += rename_request("str_rename", file_path, 5, 25)39 errcode, results = run_request(string)40 assert errcode == 041 ref = {}42 ref[path_to_uri(str(file_path))] = [create("str_rename", 5, 20, 5, 29)]43 check_rename_response(results[1]["changes"], ref)44def test_rename_var_across_module():45 """Test renaming objects like variables across modules works"""46 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})47 file_path = test_dir / "test_prog.f08"48 string += rename_request("new_module_var", file_path, 26, 15)49 errcode, results = run_request(string)50 assert errcode == 051 ref = {}52 ref[path_to_uri(str(test_dir / "subdir" / "test_free.f90"))] = [53 create("new_module_var", 32, 11, 32, 26)54 ]55 ref[path_to_uri(str(file_path))] = [create("new_module_var", 2, 44, 2, 59)]56 ref[path_to_uri(str(file_path))].append(create("new_module_var", 26, 8, 26, 23))57 check_rename_response(results[1]["changes"], ref)58def test_rename_empty():59 """Test that renaming nothing will not error"""60 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})61 file_path = test_dir / "rename" / "test_rename_imp_type_bound_proc.f90"62 string += rename_request("bar", file_path, 9, 0)63 errcode, results = run_request(string, ["-n", "1"])64 assert errcode == 065 assert results[1] is None66def test_rename_member_type_ptr():67 """Test that renaming type bound pointers of procedure methods rename68 only the pointer and not the implementation, even if the pointer and the69 implementation share the same name70 """71 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})72 file_path = test_dir / "test_prog.f08"73 string += rename_request("bp_rename", file_path, 18, 25)74 errcode, results = run_request(string)75 assert errcode == 076 ref = {}77 ref[path_to_uri(str(file_path))] = [create("bp_rename", 18, 16, 18, 26)]78 ref[path_to_uri(str(test_dir / "subdir" / "test_free.f90"))] = [79 create("bp_rename", 15, 27, 15, 37)80 ]81 check_rename_response(results[1]["changes"], ref)82def test_rename_member_type_ptr_null():83 """Test renaming type bound pointers of procedure methods works when pointing to84 null85 """86 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})87 file_path = test_dir / "test_prog.f08"88 string += rename_request("bp_rename", file_path, 17, 25)89 errcode, results = run_request(string)90 assert errcode == 091 ref = {}92 ref[path_to_uri(str(file_path))] = [create("bp_rename", 17, 16, 17, 28)]93 ref[path_to_uri(str(test_dir / "subdir" / "test_free.f90"))] = [94 create("bp_rename", 11, 43, 11, 55)95 ]96 check_rename_response(results[1]["changes"], ref)97def test_rename_type_bound_proc_no_ptr():98 """Test renaming type bound pointers of procedure methods works when no pointer99 is setup. Requesting to rename the procedure should rename, the implementation100 and the Method itself i.e. call self%foo()101 Requesting to rename the implementation should also rename the procedure102 and all the locations it is called in103 """104 root = test_dir / "rename"105 string = write_rpc_request(1, "initialize", {"rootPath": str(root)})106 file_path = root / "test_rename_imp_type_bound_proc.f90"107 # Rename the procedure name and check if implementation also renames108 string += rename_request("bar", file_path, 5, 23)109 # Rename the implementation name and check if declaration, references change110 string += rename_request("bar", file_path, 10, 18)111 errcode, results = run_request(string)112 assert errcode == 0113 ref = {}114 ref[path_to_uri(str(file_path))] = [create("bar", 5, 21, 5, 24)]115 ref[path_to_uri(str(file_path))].append(create("bar", 10, 15, 10, 18))116 ref[path_to_uri(str(file_path))].append(create("bar", 12, 18, 12, 21))117 ref[path_to_uri(str(file_path))].append(create("bar", 13, 19, 13, 22))118 check_rename_response(results[1]["changes"], ref)119 check_rename_response(results[2]["changes"], ref)120def test_rename_non_existent_file():121 """Test renaming type bound pointers of procedure methods works when pointing to122 null123 """124 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})125 file_path = test_dir / "fake.f90"126 string += rename_request("bar", file_path, 5, 23)127 errcode, results = run_request(string)128 assert errcode == 0129 assert results[1] is None130def test_rename_nested():131 """Test renaming heavily nested constructs works"""132 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})133 file_path = test_dir / "rename" / "test_rename_nested.f90"134 string += rename_request("bar", file_path, 6, 23)135 errcode, results = run_request(string, ["-n", "1"])136 assert errcode == 0137 ref = {}138 ref[path_to_uri(str(file_path))] = [create("bar", 6, 23, 6, 26)]139 ref[path_to_uri(str(file_path))].append(create("bar", 9, 27, 9, 30))140 check_rename_response(results[1]["changes"], ref)141def test_rename_intrinsic():142 """Test renaming an intrinsic function, while no other function exists143 with the same name, will throw an error144 """145 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})146 file_path = test_dir / "rename" / "test_rename_nested.f90"147 string += rename_request("bar", file_path, 8, 27)148 errcode, results = run_request(string, ["-n", "1"])149 assert errcode == 0150 check_post_msg(results[1], "Rename failed: Cannot rename intrinsics", 2)151 assert results[2] is None152def test_rename_use_only_rename():153 """Test renaming constructs of `use mod, only: val => root_val154 are handled correctly155 """156 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "subdir")})157 file_path = test_dir / "subdir" / "test_rename.F90"158 string += rename_request("bar", file_path, 13, 5)159 errcode, results = run_request(string, ["-n", "1"])160 # FIXME: to be implemented161 assert errcode == 0162def test_rename_skip_intrinsic():163 """Test that renaming functions named the same as intrinsic functions e.g. size()164 will only rename the user defined functions165 """166 string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})167 file_path = test_dir / "rename" / "test_rename_intrinsic.f90"168 string += rename_request("bar", file_path, 22, 13)169 errcode, results = run_request(string, ["-n", "1"])170 # FIXME: to be implemented...

Full Screen

Full Screen

vdisk_devgrp_modify20.py

Source:vdisk_devgrp_modify20.py Github

copy

Full Screen

...61 if self._configuration.client_side_validation and operation is None:62 raise ValueError("Invalid value for `operation`, must not be `None`") # noqa: E50163 self._operation = operation64 @property65 def rename_request(self):66 """Gets the rename_request of this VdiskDevgrpModify20. # noqa: E50167 :return: The rename_request of this VdiskDevgrpModify20. # noqa: E50168 :rtype: VdiskDeviceGroupRename69 """70 return self._rename_request71 @rename_request.setter72 def rename_request(self, rename_request):73 """Sets the rename_request of this VdiskDevgrpModify20.74 :param rename_request: The rename_request of this VdiskDevgrpModify20. # noqa: E50175 :type: VdiskDeviceGroupRename76 """77 self._rename_request = rename_request78 @property79 def kvm_set_clear_request(self):80 """Gets the kvm_set_clear_request of this VdiskDevgrpModify20. # noqa: E50181 :return: The kvm_set_clear_request of this VdiskDevgrpModify20. # noqa: E50182 :rtype: VdiskDeviceGroupKvmSetClear83 """84 return self._kvm_set_clear_request85 @kvm_set_clear_request.setter86 def kvm_set_clear_request(self, kvm_set_clear_request):...

Full Screen

Full Screen

api.py

Source:api.py Github

copy

Full Screen

1import argparse2from asset.description import description3from api.list import list4from api.new import new5from api.delete import delete6from api.practice import practice7from api.rename import rename8def _api():9 """The API contract.10 11 Defines the API endpoints.12 Returns:13 [type]: [description]14 """15 api = argparse.ArgumentParser(description=description)16 # see api.list.list17 help = """18 List exercise groups: -l <group-1> [<group-2> ... <group-N>]19 """20 api.add_argument(21 "-l", "--list",22 help=help,23 nargs='*',24 type=str25 )26 # see api.practice.practice27 help = """28 Practice a full group exercises: -p <group>29 Practice a group exercise: -p <group> <exercise>30 """31 api.add_argument(32 "-p", "--practice",33 help=help,34 type=str,35 nargs='+'36 )37 # see api.score.score38 help = """39 Score an exercise : -s <group> <exercise> <score=[0-5]>40 """41 api.add_argument(42 "-s", "--score",43 help=help,44 type=str,45 nargs=346 )47 48 # see api.new.new49 help = """50 Add a new exercise: -n <group> <exercise>51 """52 api.add_argument(53 "-n", "--new",54 help=help,55 type=str,56 nargs=257 )58 # see api.rename.rename59 help = """60 Rename an existing exercise: -r <group> <exercise> <renamed-exercise>61 Rename an existing group: -r <group> <renamed-group>62 """63 api.add_argument(64 "-r", "--rename",65 help=help,66 type=str,67 nargs=368 )69 70 # see api.delete.delete71 help = """72 Delete an existing exercise: -d <group> <exercise>73 Delete an existing group: -d <group>74 """75 api.add_argument(76 "-d", "--delete",77 help=help,78 type=str,79 nargs=280 )81 return api82def handle_request():83 """Handle a request to the API84 Returns:85 [type]: [description]86 """87 api = _api()88 request = api.parse_args()89 list_request = request.list90 new_request = request.new91 rename_request = request.rename92 del_request = request.delete93 practice_request = request.practice94 # praxis --list95 if list_request is not None:96 groups = list_request97 list(groups)98 # praxis --new99 elif new_request:100 group, exercise = new_request101 new(group, exercise)102 # praxis --rename103 elif rename_request:104 group, exercise, exercise_new = rename_request105 rename(group, exercise, exercise_new)106 # praxis --delete107 elif del_request:108 group, exercise = del_request109 delete(group, exercise)110 # praxis --practice111 elif practice_request:112 group = None113 exercise = None114 if len(practice_request) == 1:115 group = practice_request[0]116 else:117 group, exercise = practice_request118 practice(group, exercise)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run locust automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful