@@ -535,13 +535,16 @@ def test_invoke_grpc(self) -> None:
535
535
self .assertIsNotNone (response )
536
536
self .assertEqual (response .response , payload )
537
537
538
+
538
539
class TestShowHeadersJS (TinyFaaSTest ):
539
540
fn = ""
540
541
541
542
@classmethod
542
543
def setUpClass (cls ) -> None :
543
544
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
+ )
545
548
546
549
def setUp (self ) -> None :
547
550
super (TestShowHeadersJS , self ).setUp ()
@@ -563,14 +566,15 @@ def test_invoke_http(self) -> None:
563
566
response_body = res .read ().decode ("utf-8" )
564
567
response_json = json .loads (response_body )
565
568
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
567
572
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
569
574
570
575
return
571
576
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
574
578
575
579
def test_invoke_grpc (self ) -> None :
576
580
"""invoke a function"""
@@ -591,22 +595,30 @@ def test_invoke_grpc(self) -> None:
591
595
with grpc .insecure_channel (f"{ self .host } :{ self .grpc_port } " ) as channel :
592
596
stub = tinyfaas_pb2_grpc .TinyFaaSStub (channel )
593
597
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 ,
595
600
)
596
601
597
602
response_json = json .loads (response .response )
598
603
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
600
607
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
602
609
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.
604
614
fn = ""
605
615
606
616
@classmethod
607
617
def setUpClass (cls ) -> None :
608
618
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
+ )
610
622
611
623
def setUp (self ) -> None :
612
624
super (TestShowHeaders , self ).setUp ()
@@ -628,13 +640,15 @@ def test_invoke_http(self) -> None:
628
640
response_body = res .read ().decode ("utf-8" )
629
641
response_json = json .loads (response_body )
630
642
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
632
646
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
634
648
635
649
return
636
650
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
638
652
639
653
def test_invoke_grpc (self ) -> None :
640
654
"""invoke a function"""
@@ -655,15 +669,18 @@ def test_invoke_grpc(self) -> None:
655
669
with grpc .insecure_channel (f"{ self .host } :{ self .grpc_port } " ) as channel :
656
670
stub = tinyfaas_pb2_grpc .TinyFaaSStub (channel )
657
671
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 ,
659
674
)
660
675
661
676
response_json = json .loads (response .response )
662
677
663
678
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
665
682
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
667
684
668
685
669
686
if __name__ == "__main__" :
0 commit comments