@@ -599,6 +599,30 @@ def test_statsbeat_500(self):
599599 self .assertEqual (_requests_map ['count' ], 1 )
600600 self .assertEqual (result , TransportStatusCode .RETRY )
601601
602+ def test_transmission_502 (self ):
603+ mixin = TransportMixin ()
604+ mixin .options = Options ()
605+ with LocalFileStorage (os .path .join (TEST_FOLDER , self .id ())) as stor :
606+ mixin .storage = stor
607+ mixin .storage .put ([1 , 2 , 3 ])
608+ with mock .patch ('requests.post' ) as post :
609+ post .return_value = MockResponse (502 , 'unknown' )
610+ mixin ._transmit_from_storage ()
611+ self .assertIsNone (mixin .storage .get ())
612+ self .assertEqual (len (os .listdir (mixin .storage .path )), 1 )
613+
614+ def test_statsbeat_502 (self ):
615+ mixin = TransportMixin ()
616+ mixin .options = Options ()
617+ with mock .patch ('requests.post' ) as post :
618+ post .return_value = MockResponse (502 , 'unknown' )
619+ result = mixin ._transmit ([1 , 2 , 3 ])
620+ self .assertEqual (len (_requests_map ), 3 )
621+ self .assertIsNotNone (_requests_map ['duration' ])
622+ self .assertEqual (_requests_map ['retry' ][502 ], 1 )
623+ self .assertEqual (_requests_map ['count' ], 1 )
624+ self .assertEqual (result , TransportStatusCode .RETRY )
625+
602626 def test_transmission_503 (self ):
603627 mixin = TransportMixin ()
604628 mixin .options = Options ()
@@ -623,6 +647,30 @@ def test_statsbeat_503(self):
623647 self .assertEqual (_requests_map ['count' ], 1 )
624648 self .assertEqual (result , TransportStatusCode .RETRY )
625649
650+ def test_transmission_504 (self ):
651+ mixin = TransportMixin ()
652+ mixin .options = Options ()
653+ with LocalFileStorage (os .path .join (TEST_FOLDER , self .id ())) as stor :
654+ mixin .storage = stor
655+ mixin .storage .put ([1 , 2 , 3 ])
656+ with mock .patch ('requests.post' ) as post :
657+ post .return_value = MockResponse (504 , 'unknown' )
658+ mixin ._transmit_from_storage ()
659+ self .assertIsNone (mixin .storage .get ())
660+ self .assertEqual (len (os .listdir (mixin .storage .path )), 1 )
661+
662+ def test_statsbeat_504 (self ):
663+ mixin = TransportMixin ()
664+ mixin .options = Options ()
665+ with mock .patch ('requests.post' ) as post :
666+ post .return_value = MockResponse (504 , 'unknown' )
667+ result = mixin ._transmit ([1 , 2 , 3 ])
668+ self .assertEqual (len (_requests_map ), 3 )
669+ self .assertIsNotNone (_requests_map ['duration' ])
670+ self .assertEqual (_requests_map ['retry' ][504 ], 1 )
671+ self .assertEqual (_requests_map ['count' ], 1 )
672+ self .assertEqual (result , TransportStatusCode .RETRY )
673+
626674 def test_transmission_401 (self ):
627675 mixin = TransportMixin ()
628676 mixin .options = Options ()
0 commit comments