Skip to content

Commit

Permalink
Rename PfsApi and MsApi to PFSApi and MSApi
Browse files Browse the repository at this point in the history
  • Loading branch information
palango committed Jun 9, 2020
1 parent ca3403b commit 176e4f5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/monitoring_service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class MSResource(Resource):
def __init__(self, monitoring_service: MonitoringService, api: "MsApi"):
def __init__(self, monitoring_service: MonitoringService, api: "MSApi"):
self.monitoring_service = monitoring_service
self.service_token_address = (
self.monitoring_service.context.user_deposit_contract.functions.token().call()
Expand Down Expand Up @@ -53,7 +53,7 @@ def get(self) -> Tuple[dict, int]:
return info, 200


class MsApi:
class MSApi:
def __init__(
self,
monitoring_service: MonitoringService,
Expand Down
4 changes: 2 additions & 2 deletions src/monitoring_service/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from web3 import Web3
from web3.contract import Contract

from monitoring_service.api import MsApi
from monitoring_service.api import MSApi
from monitoring_service.constants import DEFAULT_INFO_MESSAGE, DEFAULT_MIN_REWARD, MS_DISCLAIMER
from monitoring_service.service import MonitoringService
from raiden.settings import DEFAULT_NUMBER_OF_BLOCK_CONFIRMATIONS
Expand Down Expand Up @@ -137,7 +137,7 @@ def main( # pylint: disable=too-many-arguments,too-many-locals
task = spawn_named("MonitoringService", service.start)

log.debug("Starting API")
api = MsApi(monitoring_service=service, operator=operator, info_message=info_message)
api = MSApi(monitoring_service=service, operator=operator, info_message=info_message)
api.run(host=host, port=port)

task.get()
Expand Down
4 changes: 2 additions & 2 deletions src/pathfinding_service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@


class PathfinderResource(Resource):
def __init__(self, pathfinding_service: PathfindingService, api: "PfsApi"):
def __init__(self, pathfinding_service: PathfindingService, api: "PFSApi"):
self.pathfinding_service = pathfinding_service
self.api = api

Expand Down Expand Up @@ -508,7 +508,7 @@ def get(self) -> Tuple[dict, int]:
)


class PfsApi:
class PFSApi:
# pylint: disable=too-many-instance-attributes
# Nine is reasonable in this case.

Expand Down
4 changes: 2 additions & 2 deletions src/pathfinding_service/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from web3 import Web3
from web3.contract import Contract

from pathfinding_service.api import PfsApi
from pathfinding_service.api import PFSApi
from pathfinding_service.constants import DEFAULT_INFO_MESSAGE, PFS_DISCLAIMER
from pathfinding_service.service import PathfindingService
from raiden.settings import DEFAULT_NUMBER_OF_BLOCK_CONFIRMATIONS
Expand Down Expand Up @@ -130,7 +130,7 @@ def main( # pylint: disable=too-many-arguments,too-many-locals
raise Exception("PFS did not start within time.")

log.debug("Starting API")
api = PfsApi(
api = PFSApi(
pathfinding_service=service,
service_fee=service_fee,
debug_mode=enable_debug,
Expand Down
6 changes: 3 additions & 3 deletions tests/monitoring/fixtures/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from eth_utils import to_checksum_address
from tests.libs.mocks.web3 import Web3Mock

from monitoring_service.api import MsApi
from monitoring_service.api import MSApi
from monitoring_service.constants import API_PATH
from monitoring_service.service import MonitoringService
from raiden.utils.typing import BlockTimeout
Expand Down Expand Up @@ -51,8 +51,8 @@ def monitoring_service_mock() -> Generator[MonitoringService, None, None]:


@pytest.fixture
def ms_api_sut(monitoring_service_mock: MonitoringService, free_port: int) -> Iterator[MsApi]:
api = MsApi(monitoring_service=monitoring_service_mock, operator="")
def ms_api_sut(monitoring_service_mock: MonitoringService, free_port: int) -> Iterator[MSApi]:
api = MSApi(monitoring_service=monitoring_service_mock, operator="")
api.run(host=DEFAULT_API_HOST, port=free_port)
yield api
api.stop()
4 changes: 2 additions & 2 deletions tests/monitoring/monitoring_service/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import requests
from eth_utils import to_checksum_address

from monitoring_service.api import MsApi
from monitoring_service.api import MSApi
from monitoring_service.constants import DEFAULT_INFO_MESSAGE
from monitoring_service.service import MonitoringService


def test_get_info(api_url: str, ms_api_sut: MsApi, monitoring_service_mock: MonitoringService):
def test_get_info(api_url: str, ms_api_sut: MSApi, monitoring_service_mock: MonitoringService):
monitoring_service_mock.context.min_reward = 123
ms_api_sut.operator = "John Doe"
url = api_url + "/info"
Expand Down
10 changes: 5 additions & 5 deletions tests/pathfinding/fixtures/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from pathfinding_service.api import PfsApi
from pathfinding_service.api import PFSApi
from pathfinding_service.constants import API_PATH
from pathfinding_service.service import PathfindingService
from raiden.utils.typing import Address
Expand All @@ -23,9 +23,9 @@ def api_sut(
reachability_state: SimpleReachabilityContainer,
free_port: int,
populate_token_network_case_1, # pylint: disable=unused-argument
) -> Iterator[PfsApi]:
) -> Iterator[PFSApi]:
pathfinding_service_mock.matrix_listener.user_manager = reachability_state
api = PfsApi(
api = PFSApi(
pathfinding_service=pathfinding_service_mock,
one_to_n_address=Address(bytes([1] * 20)),
operator="",
Expand All @@ -41,9 +41,9 @@ def api_sut_with_debug(
reachability_state: SimpleReachabilityContainer,
free_port: int,
populate_token_network_case_1, # pylint: disable=unused-argument
) -> Iterator[PfsApi]:
) -> Iterator[PFSApi]:
pathfinding_service_mock.matrix_listener.user_manager = reachability_state
api = PfsApi(
api = PFSApi(
pathfinding_service=pathfinding_service_mock,
one_to_n_address=Address(bytes([1] * 20)),
debug_mode=True,
Expand Down
12 changes: 6 additions & 6 deletions tests/pathfinding/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tests.pathfinding.test_database import db_has_feedback_for

import pathfinding_service.exceptions as exceptions
from pathfinding_service.api import DEFAULT_MAX_PATHS, PfsApi, last_failed_requests
from pathfinding_service.api import DEFAULT_MAX_PATHS, PFSApi, last_failed_requests
from pathfinding_service.constants import DEFAULT_INFO_MESSAGE
from pathfinding_service.model import IOU, TokenNetwork
from pathfinding_service.model.feedback import FeedbackToken
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_get_paths_via_debug_endpoint_empty_routes(


def test_get_ious_via_debug_endpoint(
api_sut_with_debug: PfsApi, api_url: str, addresses: List[Address]
api_sut_with_debug: PFSApi, api_url: str, addresses: List[Address]
):
hex_addrs = [to_checksum_address(addr) for addr in addresses]
iou = IOU(
Expand Down Expand Up @@ -222,7 +222,7 @@ def test_get_ious_via_debug_endpoint(
# tests for /paths endpoint
#
def test_get_paths_validation(
api_sut: PfsApi,
api_sut: PFSApi,
api_url: str,
addresses: List[Address],
token_network_model: TokenNetwork,
Expand Down Expand Up @@ -453,7 +453,7 @@ def test_get_info(api_url: str, api_sut, pathfinding_service_mock):
#
# tests for /payment/iou endpoint
#
def test_get_iou(api_sut: PfsApi, api_url: str, token_network_model: TokenNetwork, make_iou):
def test_get_iou(api_sut: PFSApi, api_url: str, token_network_model: TokenNetwork, make_iou):
privkey = get_random_privkey()
sender = private_key_to_address(privkey)
url = api_url + f"/{to_checksum_address(token_network_model.address)}/payment/iou"
Expand Down Expand Up @@ -517,7 +517,7 @@ def make_params(timestamp: str):
#
# tests for /feedback endpoint
#
def test_feedback(api_sut: PfsApi, api_url: str, token_network_model: TokenNetwork):
def test_feedback(api_sut: PFSApi, api_url: str, token_network_model: TokenNetwork):
database = api_sut.pathfinding_service.database
default_path_hex = ["0x" + "1" * 40, "0x" + "2" * 40, "0x" + "3" * 40]
default_path = [to_canonical_address(e) for e in default_path_hex]
Expand Down Expand Up @@ -571,7 +571,7 @@ def make_request(


def test_stats_endpoint(
api_sut_with_debug: PfsApi, api_url: str, token_network_model: TokenNetwork
api_sut_with_debug: PFSApi, api_url: str, token_network_model: TokenNetwork
):
database = api_sut_with_debug.pathfinding_service.database
default_path = [Address(b"1" * 20), Address(b"2" * 20), Address(b"3" * 20)]
Expand Down
4 changes: 2 additions & 2 deletions tests/pathfinding/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PATCH_ARGS = {
"target": "pathfinding_service.cli",
"PathfindingService": DEFAULT,
"PfsApi": DEFAULT,
"PFSApi": DEFAULT,
"get_web3_provider_info": MagicMock(return_value=""),
}

Expand Down Expand Up @@ -126,7 +126,7 @@ def test_shutdown(default_cli_args):
assert result.exit_code == 0
assert "Exiting" in result.output
assert mocks["PathfindingService"].return_value.stop.called
assert mocks["PfsApi"].return_value.stop.called
assert mocks["PFSApi"].return_value.stop.called


@pytest.mark.usefixtures("provider_mock")
Expand Down

0 comments on commit 176e4f5

Please sign in to comment.