Skip to content

Commit

Permalink
Merge pull request #454 from sanger/dependabot/pip/flask-3.0.2
Browse files Browse the repository at this point in the history
Bump flask from 2.2.2 to 3.0.2
  • Loading branch information
yoldas authored Feb 5, 2024
2 parents 491bee6 + eedc5f6 commit 6d3f279
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 86 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ types-flask = "*"
alembic = "~=1.10"
autoenv = "~=1.0"
colorlog = "~=6.8"
flask = "~=2.2"
flask = "~=3.0"
flask-cors = "~=3.0"
flask-sqlalchemy = "~=3.0"
gunicorn = "~=20.0"
Expand Down
165 changes: 92 additions & 73 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions baracoda/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def __validate_prefix(self) -> bool:
Returns:
bool -- whether the prefix passed validation
"""
if type(self.prefix) != str:
return False
if not isinstance(self.prefix, str):
return False # type: ignore

pattern = re.compile(r"^[A-Z0-9]{1,10}$")

Expand Down
20 changes: 10 additions & 10 deletions tests/test_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,50 @@ def test_param_empty_prefix_value(client):


def test_invalid_prefix_is_rejected(client):
response = client.post("/barcodes/TEST123412_edu/new")
response = client.post("/barcodes/TEST123412_edu/new", headers={"Content-Type": "application/json"})
assert response.status_code == HTTPStatus.BAD_REQUEST


def test_get_new_barcode(client):
response = client.post("/barcodes/SANG/new")
response = client.post("/barcodes/SANG/new", headers={"Content-Type": "application/json"})
assert response.json == {"barcode": "SANG-30D404"}
assert response.status_code == HTTPStatus.CREATED


def test_get_new_barcode_for_ht(client):
response = client.post("/barcodes/HT/new")
response = client.post("/barcodes/HT/new", headers={"Content-Type": "application/json"})
assert response.json == {"barcode": "HT-111111"}
assert response.status_code == HTTPStatus.CREATED


def test_get_new_barcode_for_sqp(client):
response = client.post("/barcodes/SQPD/new")
response = client.post("/barcodes/SQPD/new", headers={"Content-Type": "application/json"})
assert response.json == {"barcode": "SQPD-1-C"}
assert response.status_code == HTTPStatus.CREATED


def test_get_new_barcode_with_text(client):
response = client.post("/barcodes/SQPD/new?text=T12")
response = client.post("/barcodes/SQPD/new?text=T12", headers={"Content-Type": "application/json"})
assert response.json == {"barcode": "SQPD-T12-1-J"}
assert response.status_code == HTTPStatus.CREATED


def test_get_new_barcode_with_wrong_text(client):
response = client.post("/barcodes/SQPD/new?text=T120")
response = client.post("/barcodes/SQPD/new?text=T120", headers={"Content-Type": "application/json"})
assert response.json == {"errors": ["InvalidTextError"]}
assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR


def test_get_new_barcodes_group_as_url_param(client):
response = client.post("/barcodes_group/SANG/new?count=3")
response = client.post("/barcodes_group/SANG/new?count=3", headers={"Content-Type": "application/json"})
resp = response.json
resp["barcodes_group"]["barcodes"].sort()
assert resp == {"barcodes_group": {"barcodes": ["SANG-30D404", "SANG-30D413", "SANG-30D422"], "id": 1}}
assert response.status_code == HTTPStatus.CREATED


def test_get_new_barcodes_group_without_count(client):
response = client.post("/barcodes_group/SANG/new")
response = client.post("/barcodes_group/SANG/new", headers={"Content-Type": "application/json"})
assert response.status_code == HTTPStatus.BAD_REQUEST


Expand All @@ -66,7 +66,7 @@ def test_get_new_barcodes_group_with_wrong_value_count(client):


def test_get_new_barcodes_group_with_wrong_value_negative(client):
response = client.post("/barcodes_group/SANG/new?count=-124")
response = client.post("/barcodes_group/SANG/new?count=-124", headers={"Content-Type": "application/json"})
assert response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY


Expand Down Expand Up @@ -95,7 +95,7 @@ def test_get_last_barcode(client):
assert response.status_code == HTTPStatus.NOT_FOUND

# when creating barcodes
response = client.post("/barcodes/SANG/new")
response = client.post("/barcodes/SANG/new", headers={"Content-Type": "application/json"})
response = client.get("/barcodes/SANG/last")
assert response.json == {"barcode": "SANG-30D404"}
assert response.status_code == HTTPStatus.OK

0 comments on commit 6d3f279

Please sign in to comment.