Skip to content

Commit

Permalink
flake8 test files
Browse files Browse the repository at this point in the history
  • Loading branch information
iluvcapra committed Jun 28, 2023
1 parent c3b7231 commit a29500e
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations
from typing import Optional, Any, cast
from typing import cast
from unittest import TestCase
from unittest.mock import Mock, patch
from contextlib import contextmanager
from unittest.mock import patch

from google.protobuf import json_format

Expand All @@ -17,24 +16,29 @@ def __init__(self, session_id: str = "") -> None:
self.register_connection_run = False

def assert_send_request_called(self):
assert self.send_request_called, "SendGrpcRequest was not called"
assert self.send_request_called, \
"SendGrpcRequest was not called"

def assert_register_connection_run(self):
assert self.register_connection_run, "RegisterConnection command was not run"
assert self.register_connection_run, \
"RegisterConnection command was not run"

def SendGrpcRequest(self, request: pt.Request, _context = None) -> pt.Response:
def SendGrpcRequest(
self,
request: pt.Request,
_context=None) -> pt.Response:
self.send_request_called = True
response_body_json = None
response_body_json = None
if request.header.command == pt.RegisterConnection:
response_body_json=json_format.MessageToJson(
response_body_json = json_format.MessageToJson(
pt.RegisterConnectionResponseBody(session_id=self.session_id)
)
self.register_connection_run = True

return pt.Response(
header=pt.ResponseHeader(
task_id=request.header.task_id,
command=request.header.command,
task_id=request.header.task_id,
command=request.header.command,
status=pt.Completed,
progress=100),
response_body_json=response_body_json,
Expand All @@ -50,10 +54,13 @@ def test_register_session(self):

with open_client(company_name='Test',
application_name='Test') as client:

self.assertIsNotNone(client)
self.assertTrue(client.is_open)
self.assertEqual(client.session_id, "abc123")
cast(MockPtslStub, client.raw_client).assert_send_request_called()
cast(MockPtslStub, client.raw_client).assert_register_connection_run()

cast(
MockPtslStub,
client.raw_client).assert_send_request_called()
cast(
MockPtslStub,
client.raw_client).assert_register_connection_run()

0 comments on commit a29500e

Please sign in to comment.