@@ -639,3 +639,45 @@ def test_summary_is_called_with_date_range_from_worked_time_module(
639
639
repository_find_all_mock .assert_called_once_with (
640
640
ANY , conditions = conditions , date_range = date_range
641
641
)
642
+
643
+
644
+ def test_paginated_fails_with_no_params (
645
+ client : FlaskClient , valid_header : dict ,
646
+ ):
647
+ response = client .get ('/time-entries/paginated' , headers = valid_header )
648
+ assert HTTPStatus .BAD_REQUEST == response .status_code
649
+
650
+
651
+ def test_paginated_succeeds_with_valid_params (
652
+ client : FlaskClient , valid_header : dict ,
653
+ ):
654
+ response = client .get (
655
+ '/time-entries/paginated?start=10&length=10' , headers = valid_header
656
+ )
657
+ assert HTTPStatus .OK == response .status_code
658
+
659
+
660
+ def test_paginated_response_contains_expected_props (
661
+ client : FlaskClient , valid_header : dict ,
662
+ ):
663
+ response = client .get (
664
+ '/time-entries/paginated?start=10&length=10' , headers = valid_header
665
+ )
666
+ assert 'data' in json .loads (response .data )
667
+ assert 'records_total' in json .loads (response .data )
668
+
669
+
670
+ def test_paginated_sends_max_count_and_offset_on_call_to_repository (
671
+ client : FlaskClient , valid_header : dict , time_entries_dao
672
+ ):
673
+ time_entries_dao .repository .find_all = Mock (return_value = [])
674
+
675
+ response = client .get (
676
+ '/time-entries/paginated?start=10&length=10' , headers = valid_header
677
+ )
678
+
679
+ time_entries_dao .repository .find_all .assert_called_once ()
680
+
681
+ args , kwargs = time_entries_dao .repository .find_all .call_args
682
+ assert 'max_count' in kwargs and kwargs ['max_count' ] is not None
683
+ assert 'offset' in kwargs and kwargs ['offset' ] is not None
0 commit comments