Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andgineer committed Sep 15, 2021
1 parent dbc5a22 commit fa3b5ab
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/fake_jsonplaceholder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from typing import Any, Dict, Optional

FAKE_RESP = {
("GET", "/posts"): [{"id": 1}, {"id": 2}, {"id": 3}],
Expand All @@ -10,19 +11,25 @@

class FakeResp:
status = 200
body = None
body: Optional[str] = None

def __init__(self, resp_body):
def __init__(self, resp_body: str) -> None:
self.body = resp_body

def read(self):
def read(self) -> str:
return self.body


class FakeJSONPlaceholder:
def request(self, method, path, body=None, headers=None):
def request(
self,
method: str,
path: str,
body: Optional[str] = None,
headers: Optional[Dict[str, Any]] = None,
) -> None:
self.method = method
self.path = path

def response(self):
def response(self) -> FakeResp:
return FakeResp(json.dumps(FAKE_RESP[(self.method, self.path)]))

0 comments on commit fa3b5ab

Please sign in to comment.