Skip to content

Commit 6850abc

Browse files
committed
fix tests
1 parent 191f39d commit 6850abc

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

pkg/grpc/tinyfaas/tinyfaas.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test_all.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,16 @@ def test_invoke_grpc(self) -> None:
535535
self.assertIsNotNone(response)
536536
self.assertEqual(response.response, payload)
537537

538+
538539
class TestShowHeadersJS(TinyFaaSTest):
539540
fn = ""
540541

541542
@classmethod
542543
def setUpClass(cls) -> None:
543544
super(TestShowHeadersJS, cls).setUpClass()
544-
cls.fn = startFunction(path.join(fn_path, "show-headers-js"), "headersjs", "nodejs", 1)
545+
cls.fn = startFunction(
546+
path.join(fn_path, "show-headers-js"), "headersjs", "nodejs", 1
547+
)
545548

546549
def setUp(self) -> None:
547550
super(TestShowHeadersJS, self).setUp()
@@ -563,14 +566,15 @@ def test_invoke_http(self) -> None:
563566
response_body = res.read().decode("utf-8")
564567
response_json = json.loads(response_body)
565568
self.assertIn("lab", response_json)
566-
self.assertEqual(response_json["lab"], "scalable_software_systems_group") # custom header
569+
self.assertEqual(
570+
response_json["lab"], "scalable_software_systems_group"
571+
) # custom header
567572
self.assertIn("user-agent", response_json)
568-
self.assertEqual(response_json["user-agent"], "Python-urllib/3.11") # python client
573+
self.assertIn("Python-urllib", response_json["user-agent"]) # python client
569574

570575
return
571576

572-
# def test_invoke_coap(self) -> None: # CoAP does not support headers
573-
577+
# def test_invoke_coap(self) -> None: # CoAP does not support headers
574578

575579
def test_invoke_grpc(self) -> None:
576580
"""invoke a function"""
@@ -591,22 +595,30 @@ def test_invoke_grpc(self) -> None:
591595
with grpc.insecure_channel(f"{self.host}:{self.grpc_port}") as channel:
592596
stub = tinyfaas_pb2_grpc.TinyFaaSStub(channel)
593597
response = stub.Request(
594-
tinyfaas_pb2.Data(functionIdentifier=self.fn, data=payload), metadata=metadata
598+
tinyfaas_pb2.Data(functionIdentifier=self.fn, data=payload),
599+
metadata=metadata,
595600
)
596601

597602
response_json = json.loads(response.response)
598603
self.assertIn("lab", response_json)
599-
self.assertEqual(response_json["lab"], "scalable_software_systems_group") # custom header
604+
self.assertEqual(
605+
response_json["lab"], "scalable_software_systems_group"
606+
) # custom header
600607
self.assertIn("user-agent", response_json)
601-
self.assertIn("grpc-python/1.64.1", response_json["user-agent"]) # client header
608+
self.assertIn("grpc-python", response_json["user-agent"]) # client header
602609

603-
class TestShowHeaders(TinyFaaSTest): # Note: In Python, the http.server module (and many other HTTP libraries) automatically capitalizes the first character of each word in the header keys.
610+
611+
class TestShowHeaders(
612+
TinyFaaSTest
613+
): # Note: In Python, the http.server module (and many other HTTP libraries) automatically capitalizes the first character of each word in the header keys.
604614
fn = ""
605615

606616
@classmethod
607617
def setUpClass(cls) -> None:
608618
super(TestShowHeaders, cls).setUpClass()
609-
cls.fn = startFunction(path.join(fn_path, "show-headers"), "headers", "python3", 1)
619+
cls.fn = startFunction(
620+
path.join(fn_path, "show-headers"), "headers", "python3", 1
621+
)
610622

611623
def setUp(self) -> None:
612624
super(TestShowHeaders, self).setUp()
@@ -628,13 +640,15 @@ def test_invoke_http(self) -> None:
628640
response_body = res.read().decode("utf-8")
629641
response_json = json.loads(response_body)
630642
self.assertIn("Lab", response_json)
631-
self.assertEqual(response_json["Lab"], "scalable_software_systems_group") # custom header
643+
self.assertEqual(
644+
response_json["Lab"], "scalable_software_systems_group"
645+
) # custom header
632646
self.assertIn("User-Agent", response_json)
633-
self.assertIn("Python-urllib", response_json["User-Agent"]) # python client
647+
self.assertIn("Python-urllib", response_json["User-Agent"]) # python client
634648

635649
return
636650

637-
# def test_invoke_coap(self) -> None: # CoAP does not support headers, instead you have
651+
# def test_invoke_coap(self) -> None: # CoAP does not support headers, instead you have
638652

639653
def test_invoke_grpc(self) -> None:
640654
"""invoke a function"""
@@ -655,15 +669,18 @@ def test_invoke_grpc(self) -> None:
655669
with grpc.insecure_channel(f"{self.host}:{self.grpc_port}") as channel:
656670
stub = tinyfaas_pb2_grpc.TinyFaaSStub(channel)
657671
response = stub.Request(
658-
tinyfaas_pb2.Data(functionIdentifier=self.fn, data=payload), metadata=metadata
672+
tinyfaas_pb2.Data(functionIdentifier=self.fn, data=payload),
673+
metadata=metadata,
659674
)
660675

661676
response_json = json.loads(response.response)
662677

663678
self.assertIn("Lab", response_json)
664-
self.assertEqual(response_json["Lab"], "scalable_software_systems_group") # custom header
679+
self.assertEqual(
680+
response_json["Lab"], "scalable_software_systems_group"
681+
) # custom header
665682
self.assertIn("User-Agent", response_json)
666-
self.assertIn("grpc-python", response_json["User-Agent"]) # client header
683+
self.assertIn("grpc-python", response_json["User-Agent"]) # client header
667684

668685

669686
if __name__ == "__main__":

0 commit comments

Comments
 (0)