test: Adds testing parameter randomness and improves overall structure
Merge request reports
Activity
added 1 commit
- dafd236d - Improves test structure for nest-module
By Timon Römer on 2022-04-07T15:12:41 (imported from GitLab)
- access-node/test/utility_functions.py 0 → 100644
9 import pytest 10 from enum import Enum 11 import requests 12 import random 13 from config import * 14 15 16 #Receives an enum or a string and converts it to a string. Throws an error if its neither a string nor an enum with a string. 17 def convert_enum_or_string_to_string(input): 18 if isinstance(input, Enum): 19 input = input.value 20 21 if isinstance(input, str): 22 return input 23 else: 24 return ValueError("Dict key is neither of type String nor Enum!") - Comment on lines +17 to +24
17 def convert_enum_or_string_to_string(input): 18 if isinstance(input, Enum): 19 input = input.value 20 21 if isinstance(input, str): 22 return input 23 else: 24 return ValueError("Dict key is neither of type String nor Enum!") 17 def convert_enum_or_string_to_string(input): 18 if isinstance(input, Enum) and isinstance(input.value, str): 19 return input.value 20 21 if isinstance(input, str): 22 return input 23 24 return ValueError("Dict key is neither of type String nor Enum!") I would argue that this style is more readable as each if is selfcontained in the things it does. Therefore when reading it, it is easier to comprehend what is happening.
By Marcel Krüger on 2022-05-19T13:33:59 (imported from GitLab)
changed this line in version 5 of the diff
By Timon Römer on 2022-05-20T11:37:55 (imported from GitLab)
- access-node/test/utility_functions.py 0 → 100644
10 from enum import Enum 11 import requests 12 import random 13 from config import * 14 15 16 #Receives an enum or a string and converts it to a string. Throws an error if its neither a string nor an enum with a string. 17 def convert_enum_or_string_to_string(input): 18 if isinstance(input, Enum): 19 input = input.value 20 21 if isinstance(input, str): 22 return input 23 else: 24 return ValueError("Dict key is neither of type String nor Enum!") 25 - access-node/test/utility_functions.py 0 → 100644
69 def apply_enabled_list(self, list): 70 assert(len(self) == len(list)) 71 72 def __len__(self): 73 return len(self.parameters) 74 75 def __getitem__(self, key): 76 return self.get_value(key) 77 78 def apply_enabled_list(self, enable_list): 79 assert(len(self) == len(enable_list)) 80 81 for i, key in enumerate(self.parameters): 82 assert(isinstance(enable_list[i], bool)) 83 self.set_enabled(key, enable_list[i]) 84 - access-node/test/utility_functions.py 0 → 100644
77 78 def apply_enabled_list(self, enable_list): 79 assert(len(self) == len(enable_list)) 80 81 for i, key in enumerate(self.parameters): 82 assert(isinstance(enable_list[i], bool)) 83 self.set_enabled(key, enable_list[i]) 84 85 def boolean_combinations(self): 86 all_combinations = list(itertools.product([True,False], repeat = len(self))) 87 for combination in all_combinations: 88 new_queryparameters = deepcopy(self) 89 new_queryparameters.apply_enabled_list(combination) 90 yield new_queryparameters 91 92 def __str__(self): - access-node/test/utility_functions.py 0 → 100644
85 def boolean_combinations(self): 86 all_combinations = list(itertools.product([True,False], repeat = len(self))) 87 for combination in all_combinations: 88 new_queryparameters = deepcopy(self) 89 new_queryparameters.apply_enabled_list(combination) 90 yield new_queryparameters 91 92 def __str__(self): 93 str_result = "{: >20} \t\t {: >20} \t\t {: >20} \n\n".format("key","value","enabled") 94 for key, (value, enabled) in self.parameters.items(): 95 str_result += "{: >20} \t\t {: >20} \t\t {: >20} \n".format(key,value,enabled) 96 #return str_result 97 return str(self.parameters) 98 99 100 #Builds and returns a HTTP-Query String including the given parameters and values changed this line in version 5 of the diff
By Timon Römer on 2022-05-20T11:37:55 (imported from GitLab)
- access-node/test/utility_functions.py 0 → 100644
136 @staticmethod 137 def get_url(): 138 return QueryDebugger.url 139 140 @staticmethod 141 def get_params(): 142 return QueryDebugger.params 143 144 @staticmethod 145 def get_result(): 146 return QueryDebugger.json_result 147 148 @staticmethod 149 def get_status(): 150 return QueryDebugger.status_code 151 - access-node/test/utility_functions.py 0 → 100644
141 def get_params(): 142 return QueryDebugger.params 143 144 @staticmethod 145 def get_result(): 146 return QueryDebugger.json_result 147 148 @staticmethod 149 def get_status(): 150 return QueryDebugger.status_code 151 152 @staticmethod 153 def generate_long_string(): 154 return QueryDebugger.generate_short_string() + "\nResponse:\n" + str(QueryDebugger.json_result) 155 156 def generate_short_string(): - access-node/test/utility_functions.py 0 → 100644
112 if is_first_parameter: 113 query_string += "?" 114 is_first_parameter = False 115 else: 116 query_string += "&" 117 118 query_string += param_name + "=" 119 120 if (isinstance(param_value,list)): 121 query_string += ','.join(map(str,param_value)) 122 else: 123 query_string += str(param_value) 124 125 return query_string 126 127 changed this line in version 6 of the diff
By Timon Römer on 2022-05-20T14:04:48 (imported from GitLab)
- nest-module/test/helper_functions.py 0 → 100644
2 import enum 3 import itertools 4 import json 5 from nturl2path import url2pathname 6 import time 7 import numbers 8 import math 9 import pytest 10 from enum import Enum 11 import requests 12 import random 13 from test_config import * 14 15 16 #Receives an enum or a string and converts it to a string. Throws an error if its neither a string nor an enum with a string. 17 def convert_enum_or_string_to_string(input): changed this line in version 6 of the diff
By Timon Römer on 2022-05-20T14:04:48 (imported from GitLab)
- nest-module/test/helper_functions.py 0 → 100644
12 import random 13 from test_config import * 14 15 16 #Receives an enum or a string and converts it to a string. Throws an error if its neither a string nor an enum with a string. 17 def convert_enum_or_string_to_string(input): 18 if isinstance(input, Enum): 19 input = input.value 20 21 if isinstance(input, str): 22 return input 23 else: 24 return ValueError("Dict key is neither of type String nor Enum!") 25 26 #Builds and returns a HTTP-Query String including the given parameters and values 27 def build_query_string(prefix_string, query_params = None): changed this line in version 6 of the diff
By Timon Römer on 2022-05-20T14:04:48 (imported from GitLab)
added 5 commits
- e4f24ee7 - removes test_get_gids
- b81e261b - simplifies structure of enum to string conversion
- c8fad339 - adds comment to utility_functions class
- dfb0b5ca - adds comments regarding the class QueryParameters
- 45049677 - comments creation of query string
By Timon Römer on 2022-05-20T11:37:55 (imported from GitLab)
Toggle commit listadded 4 commits
- 45956156 - Removes references to get_gids endpoint
- 60dfcbb7 - Removes references to get_gid endpoint
- 32228cbd - Merge branch 'feature/improved_tests' of...
- 50454936 - adds comments for QueryDebugger class
By Timon Römer on 2022-05-20T14:04:48 (imported from GitLab)
Toggle commit listadded 1 commit
- 3f6c6030 - Removes duplicate usage of helper_functions
By Timon Römer on 2022-06-01T15:15:26 (imported from GitLab)