@@ -314,15 +314,12 @@ def _order_test(
314
314
retry_interval ,
315
315
last_successful_stream_ordering ,
316
316
) in dest :
317
- self .get_success (
318
- self .store .set_destination_retry_timings (
319
- destination , failure_ts , retry_last_ts , retry_interval
320
- )
321
- )
322
- self .get_success (
323
- self .store .set_destination_last_successful_stream_ordering (
324
- destination , last_successful_stream_ordering
325
- )
317
+ self ._create_destination (
318
+ destination ,
319
+ failure_ts ,
320
+ retry_last_ts ,
321
+ retry_interval ,
322
+ last_successful_stream_ordering ,
326
323
)
327
324
328
325
# order by default (destination)
@@ -413,11 +410,9 @@ def _search_test(
413
410
_search_test (None , "foo" )
414
411
_search_test (None , "bar" )
415
412
416
- def test_get_single_destination (self ) -> None :
417
- """
418
- Get one specific destinations.
419
- """
420
- self ._create_destinations (5 )
413
+ def test_get_single_destination_with_retry_timings (self ) -> None :
414
+ """Get one specific destination which has retry timings."""
415
+ self ._create_destinations (1 )
421
416
422
417
channel = self .make_request (
423
418
"GET" ,
@@ -432,6 +427,53 @@ def test_get_single_destination(self) -> None:
432
427
# convert channel.json_body into a List
433
428
self ._check_fields ([channel .json_body ])
434
429
430
+ def test_get_single_destination_no_retry_timings (self ) -> None :
431
+ """Get one specific destination which has no retry timings."""
432
+ self ._create_destination ("sub0.example.com" )
433
+
434
+ channel = self .make_request (
435
+ "GET" ,
436
+ self .url + "/sub0.example.com" ,
437
+ access_token = self .admin_user_tok ,
438
+ )
439
+
440
+ self .assertEqual (HTTPStatus .OK , channel .code , msg = channel .json_body )
441
+ self .assertEqual ("sub0.example.com" , channel .json_body ["destination" ])
442
+ self .assertEqual (0 , channel .json_body ["retry_last_ts" ])
443
+ self .assertEqual (0 , channel .json_body ["retry_interval" ])
444
+ self .assertIsNone (channel .json_body ["failure_ts" ])
445
+ self .assertIsNone (channel .json_body ["last_successful_stream_ordering" ])
446
+
447
+ def _create_destination (
448
+ self ,
449
+ destination : str ,
450
+ failure_ts : Optional [int ] = None ,
451
+ retry_last_ts : int = 0 ,
452
+ retry_interval : int = 0 ,
453
+ last_successful_stream_ordering : Optional [int ] = None ,
454
+ ) -> None :
455
+ """Create one specific destination
456
+
457
+ Args:
458
+ destination: the destination we have successfully sent to
459
+ failure_ts: when the server started failing (ms since epoch)
460
+ retry_last_ts: time of last retry attempt in unix epoch ms
461
+ retry_interval: how long until next retry in ms
462
+ last_successful_stream_ordering: the stream_ordering of the most
463
+ recent successfully-sent PDU
464
+ """
465
+ self .get_success (
466
+ self .store .set_destination_retry_timings (
467
+ destination , failure_ts , retry_last_ts , retry_interval
468
+ )
469
+ )
470
+ if last_successful_stream_ordering is not None :
471
+ self .get_success (
472
+ self .store .set_destination_last_successful_stream_ordering (
473
+ destination , last_successful_stream_ordering
474
+ )
475
+ )
476
+
435
477
def _create_destinations (self , number_destinations : int ) -> None :
436
478
"""Create a number of destinations
437
479
@@ -440,10 +482,7 @@ def _create_destinations(self, number_destinations: int) -> None:
440
482
"""
441
483
for i in range (0 , number_destinations ):
442
484
dest = f"sub{ i } .example.com"
443
- self .get_success (self .store .set_destination_retry_timings (dest , 50 , 50 , 50 ))
444
- self .get_success (
445
- self .store .set_destination_last_successful_stream_ordering (dest , 100 )
446
- )
485
+ self ._create_destination (dest , 50 , 50 , 50 , 100 )
447
486
448
487
def _check_fields (self , content : List [JsonDict ]) -> None :
449
488
"""Checks that the expected destination attributes are present in content
0 commit comments