Skip to content

Commit

Permalink
fix for linter failing #670 (#671)
Browse files Browse the repository at this point in the history
* fix for linter failing

* Update RELEASE_NOTES.md

* fix_for_linter
  • Loading branch information
Ravisaketi authored Aug 2, 2022
1 parent 05cbe53 commit 2ceb3c9
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 15 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
### Bug fixes

- Fix issues with integration tests and backward compatibility tests
- Fix for linter failures (#670)

### Continuous Integration

Expand Down
3 changes: 1 addition & 2 deletions src/reporter/query_NTNE.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/reporter/query_NTNE1A.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/reporter/tests/test_1TNE1A.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}

Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/reporter/tests/test_1TNENA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/reporter/tests/test_NTNE.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/reporter/tests/test_NTNE1A.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand Down
3 changes: 3 additions & 0 deletions src/reporter/tests/test_NTNENA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
Expand Down
31 changes: 25 additions & 6 deletions src/translators/sql_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = ""

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/utils/tests/tenant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random


def gen_tenant_id() -> str:
tid = random.randint(1, 2**32)
return f"tenant{tid}"
2 changes: 1 addition & 1 deletion src/wq/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ceb3c9

Please sign in to comment.