diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index fa1ff586..deb932f2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -25,6 +25,7 @@ ### Bug fixes - Fix issues with integration tests and backward compatibility tests +- Fix for linter failures (#670) ### Continuous Integration diff --git a/src/reporter/query_NTNE.py b/src/reporter/query_NTNE.py index 5b27867d..c3a6e818 100644 --- a/src/reporter/query_NTNE.py +++ b/src/reporter/query_NTNE.py @@ -11,8 +11,7 @@ def query_NTNE(limit=10000, from_date=None, to_date=None, offset=0, - id_pattern = None): - + id_pattern=None): """ See /entities in API Specification quantumleap.yml diff --git a/src/reporter/query_NTNE1A.py b/src/reporter/query_NTNE1A.py index ed3dd8f5..7a530bb3 100644 --- a/src/reporter/query_NTNE1A.py +++ b/src/reporter/query_NTNE1A.py @@ -26,8 +26,7 @@ def query_NTNE1A(attr_name, # In Path geometry=None, coords=None, id_pattern=None - ): - + ): """ See /attrs/{attrName} in API Specification quantumleap.yml diff --git a/src/reporter/tests/test_1TNE1A.py b/src/reporter/tests/test_1TNE1A.py index 3532e86e..08842db1 100644 --- a/src/reporter/tests/test_1TNE1A.py +++ b/src/reporter/tests/test_1TNE1A.py @@ -100,6 +100,7 @@ def test_1TNE1A_defaults(service, reporter_dataset): obtained = r.json() assert_1TNE1A_response(obtained, expected) + @pytest.mark.parametrize("service", services) def test_1TNE1A_idPattern(service, reporter_dataset): query_params = { @@ -141,11 +142,12 @@ def test_1TNE1A_idPattern(service, reporter_dataset): obtained = r.json() assert_1TNE1A_response(obtained, expected) + @pytest.mark.parametrize("service", services) def idPattern_not_found(service): query_params = { 'idPattern': 'nothingThere', - } + } h = {'Fiware-Service': service} @@ -156,6 +158,7 @@ def idPattern_not_found(service): "description": "No records were found for such query." } + @pytest.mark.parametrize("service", services) def test_1TNE1A_one_entity(service, reporter_dataset): # Query diff --git a/src/reporter/tests/test_1TNENA.py b/src/reporter/tests/test_1TNENA.py index 3bdda925..000ee86a 100644 --- a/src/reporter/tests/test_1TNENA.py +++ b/src/reporter/tests/test_1TNENA.py @@ -102,11 +102,12 @@ def test_1TNENA_defaults(service, reporter_dataset): obtained = r.json() assert_1TNENA_response(obtained, expected) + @pytest.mark.parametrize("service", services) def test_1TNENA_idPattern(service, reporter_dataset): h = {'Fiware-Service': service} - query_params = {'idPattern':idPattern} - r = requests.get(query_url(),params= query_params, headers=h) + query_params = {'idPattern': idPattern} + r = requests.get(query_url(), params=query_params, headers=h) assert r.status_code == 200, r.text # Assert Results @@ -150,6 +151,7 @@ def test_1TNENA_idPattern(service, reporter_dataset): obtained = r.json() assert_1TNENA_response(obtained, expected) + @pytest.mark.parametrize("service", services) def idPattern_not_found(service): query_params = { @@ -163,6 +165,7 @@ def idPattern_not_found(service): "description": "No records were found for such query." } + @pytest.mark.parametrize("service", services) def test_1TNENA_one_entity(service, reporter_dataset): # Query diff --git a/src/reporter/tests/test_NTNE.py b/src/reporter/tests/test_NTNE.py index 3fae1ed2..cc4f9c98 100644 --- a/src/reporter/tests/test_NTNE.py +++ b/src/reporter/tests/test_NTNE.py @@ -71,6 +71,7 @@ def test_not_found(service): "description": "No records were found for such query." } + @pytest.mark.parametrize("service", services) def idpattern_not_found(service): query_params = { @@ -84,6 +85,7 @@ def idpattern_not_found(service): "description": "No records were found for such query." } + @pytest.mark.parametrize("service", services) def test_NTNE_type(service, reporter_dataset): # Query @@ -103,7 +105,8 @@ def test_NTNE_type(service, reporter_dataset): 'entityType': expected_type } ] - assert obtained == expected + assert obtained == expected + @pytest.mark.parametrize("service", services) def test_NTNE_idPattern(service, reporter_dataset): @@ -127,6 +130,8 @@ def test_NTNE_idPattern(service, reporter_dataset): # TODO we removed order comparison given that in # CRATE4.0 union all and order by don't work correctly with offset + + @pytest.mark.parametrize("service", services) def test_NTNE_fromDate_toDate(service, reporter_dataset): # Query diff --git a/src/reporter/tests/test_NTNE1A.py b/src/reporter/tests/test_NTNE1A.py index bb6936d1..e2cf6faa 100644 --- a/src/reporter/tests/test_NTNE1A.py +++ b/src/reporter/tests/test_NTNE1A.py @@ -18,6 +18,7 @@ idPattern = "R" + def ix_intervals(): bs = list(range(0, result_gen.time_index_size)) + [None] prod = [(i, j) for i in bs for j in bs] @@ -84,6 +85,7 @@ def test_NTNE1A_type(service, reporter_dataset): response = requests.get(query_url(), params=query_params, headers=h) assert_entities(response, [entity_id_1, entity_id_2]) + @pytest.mark.parametrize("service", services) def test_NTNE1A_type(service, reporter_dataset): query_params = { @@ -93,6 +95,7 @@ def test_NTNE1A_type(service, reporter_dataset): response = requests.get(query_url(), params=query_params, headers=h) assert_entities(response, [entity_id_1, entity_id_2]) + @pytest.mark.parametrize("service", services) def test_NTNE1A_idPattern(service, reporter_dataset): query_params = { @@ -102,6 +105,7 @@ def test_NTNE1A_idPattern(service, reporter_dataset): response = requests.get(query_url(), params=query_params, headers=h) assert_entities(response, [entity_id_1, entity_id_2]) + @pytest.mark.parametrize("service", services) def idPattern_not_found(service, reporter_dataset): query_params = { diff --git a/src/reporter/tests/test_NTNENA.py b/src/reporter/tests/test_NTNENA.py index 94a9aa2c..1afc769a 100644 --- a/src/reporter/tests/test_NTNENA.py +++ b/src/reporter/tests/test_NTNENA.py @@ -219,6 +219,7 @@ def test_NTNENA_type(service, reporter_dataset): obtained = r.json() assert obtained == expected + @pytest.mark.parametrize("service", services) def test_NTNENA_idPattern(service, reporter_dataset): # Query @@ -293,6 +294,7 @@ def test_NTNENA_idPattern(service, reporter_dataset): obtained = r.json() assert obtained == expected + @pytest.mark.parametrize("service", services) def idPattern_not_found(service, reporter_dataset): query_params = { @@ -305,6 +307,7 @@ def idPattern_not_found(service, reporter_dataset): "description": "No records were found for such query." } + @pytest.mark.parametrize("service", services) def test_NTNE1A_one_entity(service, reporter_dataset): # Query diff --git a/src/translators/sql_translator.py b/src/translators/sql_translator.py index 044b24a7..2b4f508e 100644 --- a/src/translators/sql_translator.py +++ b/src/translators/sql_translator.py @@ -461,7 +461,6 @@ def _attr_is_structured(self, a): @staticmethod def is_text(attr_type): - return attr_type == NGSI_TEXT or attr_type not in NGSI_TO_SQL def _preprocess_values(self, e, original_attrs, col_names, @@ -798,8 +797,15 @@ def _get_limit(self, limit, last_n): f"last_n should be >=1 and <= {default_limit}.") return min(last_n, limit) - def _get_where_clause(self, entity_ids, from_date, to_date, idPattern, fiware_sp='/', - geo_query=None, prefix=''): + def _get_where_clause( + self, + entity_ids, + from_date, + to_date, + idPattern, + fiware_sp='/', + geo_query=None, + prefix=''): clauses = [] where_clause = "" @@ -827,7 +833,13 @@ def _get_where_clause(self, entity_ids, from_date, to_date, idPattern, fiware_sp clauses.append(" " + prefix + FIWARE_SERVICEPATH + " = ''") if idPattern: - clauses.append( " " + prefix + ENTITY_ID_COL + " ~* '" + idPattern + "($|.*)'") + clauses.append( + " " + + prefix + + ENTITY_ID_COL + + " ~* '" + + idPattern + + "($|.*)'") # TODO implement prefix also for geo_clause geo_clause = self._get_geo_clause(geo_query) @@ -1535,8 +1547,15 @@ def delete_entity(self, eid, etype=None, from_date=None, fiware_service=fiware_service, fiware_servicepath=fiware_servicepath) - def delete_entities(self, etype, eid=None, from_date=None, to_date=None, - idPattern=None, fiware_service=None, fiware_servicepath='/'): + def delete_entities( + self, + etype, + eid=None, + from_date=None, + to_date=None, + idPattern=None, + fiware_service=None, + fiware_servicepath='/'): table_name = self._et2tn(etype, fiware_service) where_clause = self._get_where_clause(eid, from_date, diff --git a/src/utils/tests/tenant.py b/src/utils/tests/tenant.py index 56881826..8ba34b53 100644 --- a/src/utils/tests/tenant.py +++ b/src/utils/tests/tenant.py @@ -1,5 +1,6 @@ import random + def gen_tenant_id() -> str: tid = random.randint(1, 2**32) return f"tenant{tid}" diff --git a/src/wq/core/task.py b/src/wq/core/task.py index 8b501509..c1ff99ec 100644 --- a/src/wq/core/task.py +++ b/src/wq/core/task.py @@ -278,7 +278,7 @@ def _do_enqueue(self): except Exception as e: log().error(e) if recover_from_enqueueing_failure(): - msg="This task could not be added to the work queue, " \ + msg = "This task could not be added to the work queue, " \ "QuantumLeap will try running this task synchronously " \ "if WQ_RECOVER_FROM_ENQUEUEING_FAILURE = true" log().info(msg)