Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Jan 17, 2023
1 parent 8252095 commit cf42fdc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions fakeapi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fakeapi import FakeAPI

def fakeapi_server():
""" start http server according to args """
parser = argparse.ArgumentParser(prog = 'python -m fakeapi')
parser.add_argument("-s", "--server", type=str, default='localhost',
help="HTTP server address")
Expand Down
7 changes: 3 additions & 4 deletions fakeapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
url_config data can be loaded by json file specified in url_json.
"""
# pylint: disable=W0613,C0103,R0902,R0903
# pylint: disable=W0613,C0103,R0902,R0903,R1732

__author__ = "Franck Jouvanceau"

import json
import sys
import argparse
from copy import copy
from unittest.mock import MagicMock, patch
from . import urlfunc
Expand Down Expand Up @@ -149,7 +148,8 @@ def http_server(self, server='localhost', port=8080, http_prefix=None, start=Tru
""" start http server """
if http_prefix is None:
http_prefix = f"http://{server}:{port}"
return fakeserver.FakeAPIServer(self, http_prefix, start, (server,port), fakeserver.FakeAPIHTTPHandler)
return fakeserver.FakeAPIServer(self, http_prefix, start, (server,port),
fakeserver.FakeAPIHTTPHandler)

def mock_class(self, apicli):
""" to be called in unittest.TestCase.setUp() """
Expand Down Expand Up @@ -187,4 +187,3 @@ class MockAPI:
put = None
patch = None
delete = None

3 changes: 3 additions & 0 deletions fakeapi/fakeserver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
""" Fake API HTTP server class"""
# pylint: disable=C0103

import sys
import json
from http.server import HTTPServer, BaseHTTPRequestHandler
Expand Down
6 changes: 4 additions & 2 deletions fakeapi/urlconfighelper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
""" UrlConfigHelper to call api with url_config saving """
# pylint: disable=C0103
import json
from fakeapi import get_url
from . import urlfunc

# function with class naming convention, as creates derived class instance
def UrlConfigHelper(cliclass):
Expand All @@ -18,7 +20,7 @@ def _call(self, method, url, params=None, data=None, **kwargs):
"""
call = getattr(super(), method)
response = call(url, data=data, params=params, **kwargs)
url = get_url(response.url, data)
url = urlfunc.get_url(response.url, data)
self.url_config[f'{method.upper()} {url}'] = {
'status_code': response.status_code,
'data': response.json() if response.content else None,
Expand Down
1 change: 1 addition & 0 deletions fakeapi/urlfunc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
""" url generation functions """
from urllib.parse import urlencode, urlparse, unquote_plus #, parse_qs, quote
from requests.utils import requote_uri

Expand Down

0 comments on commit cf42fdc

Please sign in to comment.