-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgood.py
34 lines (23 loc) · 933 Bytes
/
good.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Connection:
def request(self, url: str, method: str, options: dict):
raise NotImplementedError
class Http:
"""High level class depends on the abstraction (Connection)"""
def __init__(self, http_connection: Connection):
self.http_connection = http_connection
def get(self, url: str, options: dict):
self.http_connection.request(url, 'GET', options)
def post(self, url: str, options: dict):
self.http_connection.request(url, 'POST', options)
class XMLHttpService(Connection):
def request(self, url: str, method: str, options: dict):
if method == 'GET':
print('open')
elif method == 'POST':
print('send')
class NodeHttpService(Connection):
def request(self, url: str, method: str, options: dict):
pass
class MockHttpService(Connection):
def request(self, url: str, method: str, options: dict):
pass