Skip to content

Commit

Permalink
test(chore): Tidy function names
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 18, 2024
1 parent 7b539ae commit 387d166
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions integration_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests


def req(method, path, auth=None, **kwargs):
def req(method, path, auth=None, status=200, **kwargs):
url = urljoin("http://127.0.0.1:6800", path)

for badauth in (None, ("baduser", "badpass")):
Expand All @@ -14,6 +14,6 @@ def req(method, path, auth=None, **kwargs):

response = getattr(requests, method)(url, auth=("hello12345", "67890world"), **kwargs)

assert response.status_code == 200, f"200 != {response.status_code}"
assert response.status_code == status, f"{status} != {response.status_code}"

return response
2 changes: 1 addition & 1 deletion tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def test_launch_spider_get(self, mock_scrapyd):
resp = requests.get(mock_scrapyd.urljoin("schedule.json"))

assert resp.status_code == 200
# TODO scrapyd should return status 405 Method Not Allowed not 200
assert resp.json()['status'] == 'error'

def test_spider_list_no_project(self, mock_scrapyd):
Expand All @@ -72,6 +71,7 @@ def test_spider_list_no_project(self, mock_scrapyd):

assert resp.status_code == 200
assert data['status'] == 'error'
assert data['message'] == "'project' parameter is required"

def test_spider_list_project_no_egg(self, mock_scrapyd):
resp = requests.get(mock_scrapyd.urljoin('listprojects.json'))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_schedule(self, txrequest, site_with_egg):
(b'delproject.json', False, 'render_POST'),
(b'delversion.json', False, 'render_POST'),
])
def test_bad_project_names(self, txrequest, site_no_egg, endpoint, attach_egg, method):
def test_project_directory_traversal(self, txrequest, site_no_egg, endpoint, attach_egg, method):
txrequest.args = {
b'project': [b'../p'],
b'version': [b'0.1'],
Expand All @@ -192,7 +192,7 @@ def test_bad_project_names(self, txrequest, site_no_egg, endpoint, attach_egg, m
(b'schedule.json', False, 'render_POST'),
(b'listspiders.json', False, 'render_GET'),
])
def test_bad_project_names_runner(self, txrequest, site_no_egg, endpoint, attach_egg, method):
def test_project_directory_traversal_runner(self, txrequest, site_no_egg, endpoint, attach_egg, method):
txrequest.args = {
b'project': [b'../p'],
b'spider': [b's'],
Expand Down

0 comments on commit 387d166

Please sign in to comment.