@@ -552,6 +552,117 @@ def test_ok_context_record_count(cmci_module): # type: (CMCITestHelper) -> None
552
552
'type' : 'cicslocalfile'
553
553
})
554
554
555
+ def test_fail_on_nodata_false (cmci_module ): # type: (CMCITestHelper) -> None
556
+ cmci_module .stub_nodata ('GET' , 'cicslocalfile' , fail_on_nodata = False )
557
+
558
+ cmci_module .expect (result (
559
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56/' ,
560
+ records = None ,
561
+ cpsm_response = 'NODATA' ,
562
+ cpsm_response_code = 1027
563
+ ))
564
+
565
+ cmci_module .run (cmci_get , {
566
+ 'cmci_host' : HOST ,
567
+ 'cmci_port' : PORT ,
568
+ 'context' : CONTEXT ,
569
+ 'type' : 'cicslocalfile' ,
570
+ 'fail_on_nodata' : False
571
+ })
572
+
573
+ def test_fail_on_nodata_false_record_count (cmci_module ): # type: (CMCITestHelper) -> None
574
+ cmci_module .stub_nodata ('GET' , 'cicslocalfile' , record_count = 1 , fail_on_nodata = False )
575
+
576
+ cmci_module .expect (result (
577
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56///1' ,
578
+ records = None ,
579
+ cpsm_response = 'NODATA' ,
580
+ cpsm_response_code = 1027
581
+ ))
582
+
583
+ cmci_module .run (cmci_get , {
584
+ 'cmci_host' : HOST ,
585
+ 'cmci_port' : PORT ,
586
+ 'context' : CONTEXT ,
587
+ 'type' : 'cicslocalfile' ,
588
+ 'record_count' : 1 ,
589
+ 'fail_on_nodata' : False
590
+ })
591
+
592
+ def test_fail_on_nodata_false_with_data (cmci_module ): # type: (CMCITestHelper) -> None
593
+ records = [{'name' : 'bat' , 'dsname' : 'STEWF.BLOP.BLIP' }]
594
+
595
+ cmci_module .stub_records ('GET' , 'cicslocalfile' , records , fail_on_nodata = False )
596
+
597
+ cmci_module .expect (result (
598
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56/' ,
599
+ records = records ,
600
+ ))
601
+
602
+ cmci_module .run (cmci_get , {
603
+ 'cmci_host' : HOST ,
604
+ 'cmci_port' : PORT ,
605
+ 'context' : CONTEXT ,
606
+ 'type' : 'cicslocalfile' ,
607
+ 'fail_on_nodata' : False
608
+ })
609
+
610
+ def test_fail_on_nodata_true_with_data (cmci_module ): # type: (CMCITestHelper) -> None
611
+ records = [{'name' : 'bat' , 'dsname' : 'STEWF.BLOP.BLIP' }]
612
+
613
+ cmci_module .stub_records ('GET' , 'cicslocalfile' , records , fail_on_nodata = True )
614
+
615
+ cmci_module .expect (result (
616
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56/' ,
617
+ records = records ,
618
+ ))
619
+
620
+ cmci_module .run (cmci_get , {
621
+ 'cmci_host' : HOST ,
622
+ 'cmci_port' : PORT ,
623
+ 'context' : CONTEXT ,
624
+ 'type' : 'cicslocalfile' ,
625
+ 'fail_on_nodata' : True
626
+ })
627
+
628
+ def test_fail_on_nodata_true_with_data_record_count (cmci_module ): # type: (CMCITestHelper) -> None
629
+ records = [{'name' : 'bat' , 'dsname' : 'STEWF.BLOP.BLIP' }]
630
+
631
+ cmci_module .stub_records ('GET' , 'cicslocalfile' , records , record_count = 1 , fail_on_nodata = True )
632
+
633
+ cmci_module .expect (result (
634
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56///1' ,
635
+ records = records ,
636
+ ))
637
+
638
+ cmci_module .run (cmci_get , {
639
+ 'cmci_host' : HOST ,
640
+ 'cmci_port' : PORT ,
641
+ 'context' : CONTEXT ,
642
+ 'type' : 'cicslocalfile' ,
643
+ 'record_count' : 1 ,
644
+ 'fail_on_nodata' : True
645
+ })
646
+
647
+ def test_fail_on_nodata_true (cmci_module ): # type: (CMCITestHelper) -> None
648
+ cmci_module .stub_nodata ('GET' , 'cicslocalfile' , fail_on_nodata = True )
649
+
650
+ cmci_module .expect (result (
651
+ 'https://winmvs2c.hursley.ibm.com:26040/CICSSystemManagement/cicslocalfile/CICSEX56/' ,
652
+ records = None ,
653
+ cpsm_response = 'NODATA' ,
654
+ cpsm_response_code = 1027 ,
655
+ failed = True ,
656
+ msg = 'CMCI request failed with response "NODATA" reason "1027"'
657
+ ))
658
+
659
+ cmci_module .run (cmci_get , {
660
+ 'cmci_host' : HOST ,
661
+ 'cmci_port' : PORT ,
662
+ 'context' : CONTEXT ,
663
+ 'type' : 'cicslocalfile' ,
664
+ 'fail_on_nodata' : True
665
+ })
555
666
556
667
def test_sanitise_filter_value (cmci_module ): # type: (CMCITestHelper) -> None
557
668
records = [{'applid' : 'REGION1' , 'cicsstaus' : 'ACTIVE' }]
@@ -765,22 +876,32 @@ def test_invalid_cmci_type(cmci_module): # type: (CMCITestHelper) -> None
765
876
}
766
877
})
767
878
768
-
769
- def result (url , records , http_status = 'OK' , http_status_code = 200 ):
770
- return {
879
+ def result (url , records , http_status = 'OK' , http_status_code = 200 , cpsm_response = 'OK' , cpsm_response_code = 1024 , failed = False , msg = None ):
880
+ result_dict = {
771
881
'changed' : False ,
772
882
'connect_version' : '0560' ,
773
883
'cpsm_reason' : '' ,
774
884
'cpsm_reason_code' : 0 ,
775
- 'cpsm_response' : 'OK' ,
776
- 'cpsm_response_code' : 1024 ,
885
+ 'cpsm_response' : cpsm_response ,
886
+ 'cpsm_response_code' : cpsm_response_code ,
777
887
'http_status' : http_status ,
778
888
'http_status_code' : http_status_code ,
779
- 'record_count' : len (records ),
780
- 'records' : records ,
889
+ 'record_count' : 0 ,
781
890
'request' : {
782
891
'url' : url ,
783
892
'method' : 'GET' ,
784
893
'body' : None
785
894
}
786
895
}
896
+
897
+ if records != None :
898
+ result_dict .update ({
899
+ 'records' : records ,
900
+ 'record_count' : len (records )
901
+ })
902
+ if failed == True and msg != None :
903
+ result_dict .update ({
904
+ 'failed' : True ,
905
+ 'msg' : msg
906
+ })
907
+ return result_dict
0 commit comments