Skip to content

Commit

Permalink
Don't modify private fields
Browse files Browse the repository at this point in the history
  • Loading branch information
shadromani committed Jul 17, 2024
1 parent 1bcc54c commit ba49e05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
4 changes: 2 additions & 2 deletions minfraud/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

_REQUEST_UA = f"minFraud-API/{__version__} {requests.utils.default_user_agent()}"

_SCHEME = "https"

# pylint: disable=too-many-instance-attributes, missing-class-docstring
class BaseClient:
Expand All @@ -57,8 +58,7 @@ def __init__(
self._account_id = str(account_id)
self._license_key = license_key
self._timeout = timeout

base_uri = f"https://{host}/minfraud/v2.0"
base_uri = f"{_SCHEME}://{host}/minfraud/v2.0"
self._score_uri = "/".join([base_uri, "score"])
self._insights_uri = "/".join([base_uri, "insights"])
self._factors_uri = "/".join([base_uri, "factors"])
Expand Down
22 changes: 4 additions & 18 deletions tests/test_webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
from minfraud.models import Factors, Insights, Score
from minfraud.webservice import AsyncClient, Client

import minfraud.webservice
import unittest

minfraud.webservice._SCHEME = "http"

class BaseTest(unittest.TestCase):
client_class: Union[Type[AsyncClient], Type[Client]] = Client
Expand All @@ -28,16 +30,7 @@ def setup_httpserver(self, httpserver: HTTPServer):
self.httpserver = httpserver

def setUp(self):
self.client = self.client_class(42, "abcdef123456")
self.client._base_uri = self.httpserver.url_for("/minfraud/v2.0")
self.client._factors_uri = self.httpserver.url_for("/minfraud/v2.0/factors")

self.client._insights_uri = self.httpserver.url_for("/minfraud/v2.0/insights")
self.client._score_uri = self.httpserver.url_for("/minfraud/v2.0/score")
self.client._report_uri = self.httpserver.url_for(
"/minfraud/v2.0/transactions/report"
)

self.client = self.client_class(42, "abcdef123456",host="{0}:{1}".format(self.httpserver.host,self.httpserver.port))
test_dir = os.path.join(os.path.dirname(__file__), "data")
with open(os.path.join(test_dir, self.request_file), encoding="utf-8") as file:
content = file.read()
Expand Down Expand Up @@ -241,14 +234,7 @@ def custom_handler(r):

def test_200_with_locales(self):
locales = ("fr",)
client = self.client_class(42, "abcdef123456", locales=locales)
client._base_uri = self.httpserver.url_for("/minfraud/v2.0")
client._factors_uri = self.httpserver.url_for("/minfraud/v2.0/factors")
client._insights_uri = self.httpserver.url_for("/minfraud/v2.0/insights")
client._score_uri = self.httpserver.url_for("/minfraud/v2.0/score")
client._report_uri = self.httpserver.url_for(
"minfraud/v2.0/transactions/report"
)
client = self.client_class(42, "abcdef123456", locales=locales,host="{0}:{1}".format(self.httpserver.host,self.httpserver.port))
model = self.create_success(client=client)
response = json.loads(self.response)
if self.has_ip_location():
Expand Down

0 comments on commit ba49e05

Please sign in to comment.