Skip to content

Commit

Permalink
Fixing pylint and mypy (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliporace committed Feb 22, 2024
1 parent 65066a4 commit 1eef5f0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ repos:
# ]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.770
# rev: v0.770
rev: v0.790
hooks:
- id: mypy
language_version: python3.9
Expand Down
2 changes: 1 addition & 1 deletion cbers2stac/dlq_replay/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def gather_messages(queue): # pylint: disable=missing-docstring

def send_messages(messages, queue): # pylint: disable=missing-docstring
entries = [
dict(Id=str(i + 1), MessageBody=message.body)
{"Id": str(i + 1), "MessageBody": message.body}
for i, message in enumerate(messages)
]

Expand Down
4 changes: 2 additions & 2 deletions cbers2stac/process_new_scene_queue/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def catalog_update_request(table_name: str, stac_item_key: str):
)


def process_trigger(
def process_trigger( # pylint: disable=too-many-arguments
*,
stac_bucket: str,
cog_pds_meta_pds: Dict[str, str],
Expand Down Expand Up @@ -319,7 +319,7 @@ def process_trigger(
)


def process_queue(
def process_queue( # pylint: disable=too-many-arguments
*,
stac_bucket: str,
cog_pds_meta_pds: Dict[str, str],
Expand Down
2 changes: 1 addition & 1 deletion stack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StackSettings(pydantic.BaseSettings): # pylint: disable=too-few-public-me
"""Application settings"""

name: str = "cbers2stac"
description: Optional[str] = "CBERS 4/4A and Amazonia 1 STAC catalogs"
description: str = "CBERS 4/4A and Amazonia 1 STAC catalogs"
stage: str = "production"
operator_email: str
cost_center: Optional[str]
Expand Down
28 changes: 15 additions & 13 deletions test/api_gw_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_root(api_gw_method, lambda_function):
lambda_client, lambda_func = lambda_function # pylint: disable=unused-variable

url = api_gw_lambda_integrate_deploy(api_client, api, api_resource, lambda_func)
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200


Expand Down Expand Up @@ -183,50 +183,50 @@ def test_item_search_get(
original_url = api_gw_lambda_integrate_deploy(
api_client, api, api_resource, lambda_func
)
req = requests.get(original_url)
req = requests.get(original_url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 2

# Single collection, return single item
url = f"{original_url}?collections=CBERS4-MUX"
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 1
assert fcol["features"][0]["collection"] == "CBERS4-MUX"

# Two collections, return all items
url = f"{original_url}?collections=CBERS4-MUX,CBERS4-AWFI"
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 2

# Paging, no next case
url = f"{original_url}"
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert "links" not in fcol.keys()

# Paging, next page
url = f"{original_url}?limit=1"
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert "links" in fcol.keys()
assert len(fcol["links"]) == 1
next_href = to_localstack_url(api["id"], fcol["links"][0]["href"])
req = requests.get(next_href)
req = requests.get(next_href, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert "links" not in fcol.keys()
assert fcol["features"][0]["id"] == "CBERS_4_MUX_20170528_090_084_L2"

# ids
url = f"{original_url}?ids=CBERS_4_MUX_20170528_090_084_L2"
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 1
Expand All @@ -235,7 +235,7 @@ def test_item_search_get(
# query extension
url = f"{original_url}?"
url += urlencode({"query": '{"cbers:data_type": {"eq":"L4"}}'})
req = requests.get(url)
req = requests.get(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 1
Expand Down Expand Up @@ -299,6 +299,7 @@ def test_item_search_post(
"datetime": "2019-01-01T00:00:00Z/2019-01-01T23:59:59Z",
}
),
timeout=30,
)
assert req.status_code == 400, req.text
assert "First lon corner is not western" in req.text
Expand All @@ -314,25 +315,26 @@ def test_item_search_post(
"datetime": "2019-01-01T00:00:00Z/2019-01-01T23:59:59Z",
}
),
timeout=30,
)
assert req.status_code == 200, req.text

# Paging, no next case
req = requests.post(url)
req = requests.post(url, timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert "links" not in fcol.keys()

# Paging, next page
body = {"limit": 1}
req = requests.post(url, data=json.dumps(body))
req = requests.post(url, data=json.dumps(body), timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert "links" in fcol.keys()
assert len(fcol["links"]) == 1
next_href = to_localstack_url(api["id"], fcol["links"][0]["href"])
req = requests.post(
next_href, data=json.dumps({**body, **fcol["links"][0]["body"]})
next_href, data=json.dumps({**body, **fcol["links"][0]["body"]}), timeout=30
)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
Expand All @@ -341,7 +343,7 @@ def test_item_search_post(

# ids
body = {"ids": ["CBERS_4_MUX_20170528_090_084_L2"]}
req = requests.post(url, data=json.dumps(body))
req = requests.post(url, data=json.dumps(body), timeout=30)
assert req.status_code == 200, req.text
fcol = json.loads(req.text)
assert len(fcol["features"]) == 1
Expand Down

0 comments on commit 1eef5f0

Please sign in to comment.