small changes regarding the routes
This commit is contained in:
parent
25eac9bfb4
commit
ca354063c7
@ -9,7 +9,7 @@ class TestIntGenreRead:
|
|||||||
|
|
||||||
def test_records_read(self, client, db):
|
def test_records_read(self, client, db):
|
||||||
"""test reading records"""
|
"""test reading records"""
|
||||||
response = client.get("/genre/all", follow_redirects=True)
|
response = client.get("/genre/", follow_redirects=True)
|
||||||
# good status code
|
# good status code
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# two records returned
|
# two records returned
|
||||||
@ -32,13 +32,13 @@ class TestIntGenreCreate:
|
|||||||
def test_uniqueness_constraint(self, client, db):
|
def test_uniqueness_constraint(self, client, db):
|
||||||
"""assert uniqueness constraint when adding records"""
|
"""assert uniqueness constraint when adding records"""
|
||||||
with pytest.raises(IntegrityError) as excinfo:
|
with pytest.raises(IntegrityError) as excinfo:
|
||||||
client.post("/genre/create", data={"form_Genre": "spam"})
|
client.post("/genre/create/", data={"form_Genre": "spam"})
|
||||||
assert "UNIQUE constraint failed" in str(excinfo.value)
|
assert "UNIQUE constraint failed" in str(excinfo.value)
|
||||||
|
|
||||||
def test_notempty_constraint(self, client):
|
def test_notempty_constraint(self, client):
|
||||||
"""assert non-empty constraint when adding record"""
|
"""assert non-empty constraint when adding record"""
|
||||||
with pytest.raises(IntegrityError) as excinfo:
|
with pytest.raises(IntegrityError) as excinfo:
|
||||||
client.post("/genre/create", data={"form_Genre": ""})
|
client.post("/genre/create/", data={"form_Genre": ""})
|
||||||
assert "CHECK constraint failed" in str(excinfo.value)
|
assert "CHECK constraint failed" in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class TestUnitGenreRead:
|
|||||||
Genre(ID=4, Genre="SpAm"),
|
Genre(ID=4, Genre="SpAm"),
|
||||||
Genre(ID=26, Genre="eGgS")
|
Genre(ID=26, Genre="eGgS")
|
||||||
])
|
])
|
||||||
response = client.get("/genre")
|
response = client.get("/genre/", follow_redirects=True)
|
||||||
# assert good HTTP response
|
# assert good HTTP response
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# assert two records read
|
# assert two records read
|
||||||
@ -24,13 +24,13 @@ class TestUnitGenreRead:
|
|||||||
|
|
||||||
def test_get_request_with_query(self, client):
|
def test_get_request_with_query(self, client):
|
||||||
"""test GET request with query string"""
|
"""test GET request with query string"""
|
||||||
response = client.get("/genre", query_string={"id": 1, "form_genre": "spam"})
|
response = client.get("/genre/", query_string={"id": 1, "form_genre": "spam"}, follow_redirects=True)
|
||||||
# assert good HTTP response
|
# assert good HTTP response
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
def test_post_request(self, client):
|
def test_post_request(self, client):
|
||||||
"""test POST request"""
|
"""test POST request"""
|
||||||
response = client.post("/genre")
|
response = client.post("/genre/", follow_redirects=True)
|
||||||
assert response.status_code == 405
|
assert response.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class TestUnitGenreCreate:
|
|||||||
|
|
||||||
def test_get_request(self, client):
|
def test_get_request(self, client):
|
||||||
"""test a GET request"""
|
"""test a GET request"""
|
||||||
response = client.get("/genre/create", query_string={"form_Genre": "spam & eggs"})
|
response = client.get("/genre/create/", query_string={"form_Genre": "spam & eggs"})
|
||||||
assert response.status_code == 405
|
assert response.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user