Skip to content

Commit 5a38f5e

Browse files
committed
fix: Call to user list, fix typo
1 parent 99043f7 commit 5a38f5e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

pyvulnerabilitylookup/api.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,11 @@ def create_user(self, /, *, user: dict[str, Any] | None=None,
540540
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('api', 'user'))), json=user)
541541
try:
542542
r.raise_for_status()
543-
except requests.exceptions.HTTPError:
543+
except requests.exceptions.HTTPError as e:
544544
if r.status_code == 400:
545545
# If creating the user fails, the instance returns a 400 with a content explaining what happened.
546546
return r.json()
547-
raise r
547+
raise e
548548
return r.json()
549549

550550
def list_users(self) -> Generator[dict[str, Any]]:
@@ -562,14 +562,14 @@ def get_users(self, *, page: int | None=None, per_page: int | None=None) -> dict
562562
params['page'] = page
563563
if per_page is not None:
564564
params['per_page'] = per_page
565-
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('api', 'user'))), params=params)
565+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'user'))), params=params)
566566
try:
567567
r.raise_for_status()
568-
except requests.exceptions.HTTPError:
568+
except requests.exceptions.HTTPError as e:
569569
if r.status_code == 400:
570570
# If creating the user fails, the instance returns a 400 with a content explaining what happened.
571571
return r.json()
572-
raise r
572+
raise e
573573
return r.json()
574574

575575
def get_users_iter(self) -> Generator[dict[str, Any]]:
@@ -588,23 +588,23 @@ def get_user_information(self) -> dict[str, Any]:
588588
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'user', 'me'))))
589589
try:
590590
r.raise_for_status()
591-
except requests.exceptions.HTTPError:
591+
except requests.exceptions.HTTPError as e:
592592
if r.status_code == 400:
593593
# If creating the user fails, the instance returns a 400 with a content explaining what happened.
594594
return r.json()
595-
raise r
595+
raise e
596596
return r.json()
597597

598598
def reset_api_key(self) -> dict[str, Any]:
599599
'''Reset the API key'''
600600
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'user', 'api_key'))))
601601
try:
602602
r.raise_for_status()
603-
except requests.exceptions.HTTPError:
603+
except requests.exceptions.HTTPError as e:
604604
if r.status_code == 400:
605605
# If creating the user fails, the instance returns a 400 with a content explaining what happened.
606606
return r.json()
607-
raise r
607+
raise e
608608
return r.json()
609609

610610
def delete_user(self, user_id: str) -> int:
@@ -615,11 +615,11 @@ def delete_user(self, user_id: str) -> int:
615615
r = self.session.delete(urljoin(self.root_url, str(PurePosixPath('api', 'user', user_id))))
616616
try:
617617
r.raise_for_status()
618-
except requests.exceptions.HTTPError:
618+
except requests.exceptions.HTTPError as e:
619619
if r.status_code == 400:
620620
# If creating the user fails, the instance returns a 400 with a content explaining what happened.
621621
return r.json()
622-
raise r
622+
raise e
623623
return r.status_code
624624

625625
# #### Sightings ####

tests/test_web.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def test_get_recent(self) -> None:
5858
recent_10_days = date.today() - timedelta(days=10)
5959
recent = self.client.get_recent(date_from=recent_10_days)
6060
self.assertTrue(recent)
61-
print(recent)
6261
self.assertTrue(isinstance(recent, list))
6362
recent = self.client.get_recent(date_from=recent_10_days, number=1)
6463
self.assertTrue(isinstance(recent, list))

0 commit comments

Comments
 (0)