Example #1
0
 def test_limit_is_less_than_one(self):
     """Offset should default to 1."""
     limit = -1
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=1, limit_arg=limit)
     self.assertEqual(clean_offset, 1)
     self.assertEqual(clean_limit, 1)
 def test_limit_ist_too_big(self):
     """Limit should max out at configured value."""
     limit = self.CONF.max_limit_paging + 10
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=1,
         limit_arg=limit)
     self.assertEqual(clean_limit, self.CONF.max_limit_paging)
 def test_offset_as_uncastable_str(self):
     """ When Offset cannot be cast to an int, it should be zero """
     limit = self.CONF.default_limit_paging
     clean_offset, clean_limit = clean_paging_values(offset_arg='boom',
                                                     limit_arg=limit)
     self.assertEqual(clean_offset, 0)
     self.assertEqual(clean_limit, limit)
Example #4
0
 def test_offset_as_uncastable_str(self):
     """ When Offset cannot be cast to an int, it should be zero """
     limit = self.CONF.default_limit_paging
     clean_offset, clean_limit = clean_paging_values(offset_arg='boom',
                                                     limit_arg=limit)
     self.assertEqual(clean_offset, 0)
     self.assertEqual(clean_limit, limit)
Example #5
0
    def test_offset_as_none(self):
        """When Offset is set to None it should use an offset of 0."""
        clean_offset, clean_limit = repositories.clean_paging_values(
            offset_arg=None, limit_arg=self.default_limit)

        self.assertEqual(0, clean_offset)
        self.assertEqual(self.default_limit, clean_limit)
Example #6
0
 def test_offset_as_uncastable_str(self):
     """When Offset cannot be cast to an int, it should be zero."""
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg='boom',
         limit_arg=self.default_limit)
     self.assertEqual(0, clean_offset)
     self.assertEqual(self.default_limit, clean_limit)
Example #7
0
 def test_limit_is_too_big(self):
     """Limit should max out at configured value."""
     limit = self.CONF.max_limit_paging + 10
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=1,
         limit_arg=limit)
     self.assertEqual(self.CONF.max_limit_paging, clean_limit)
Example #8
0
 def test_offset_is_too_big(self):
     """When Offset exceeds sys.maxsize, it should be zero."""
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=265613988875874769338781322035779626829233452653394495,
         limit_arg=self.default_limit)
     self.assertEqual(0, clean_offset)
     self.assertEqual(self.default_limit, clean_limit)
Example #9
0
 def test_offset_as_uncastable_str(self):
     """When Offset cannot be cast to an int, it should be zero."""
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg='boom',
         limit_arg=self.default_limit)
     self.assertEqual(0, clean_offset)
     self.assertEqual(self.default_limit, clean_limit)
Example #10
0
 def test_limit_as_uncastable_str(self):
     """When Limit cannot be cast to an int, expect the default."""
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=0,
         limit_arg='boom')
     self.assertEqual(0, clean_offset)
     self.assertEqual(self.default_limit, clean_limit)
Example #11
0
 def test_limit_as_uncastable_str(self):
     """When Limit cannot be cast to an int, expect the default."""
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=0,
         limit_arg='boom')
     self.assertEqual(clean_offset, 0)
     self.assertEqual(clean_limit, self.CONF.default_limit_paging)
Example #12
0
 def test_limit_is_less_than_one(self):
     """Offset should default to 1"""
     limit = -1
     clean_offset, clean_limit = clean_paging_values(offset_arg=1,
                                                     limit_arg=limit)
     self.assertEqual(clean_offset, 1)
     self.assertEqual(clean_limit, 1)
Example #13
0
    def test_offset_as_none(self):
        """ When Offset is set to None it should use an offset of 0 """
        limit = self.CONF.default_limit_paging
        clean_offset, clean_limit = clean_paging_values(offset_arg=None,
                                                        limit_arg=limit)

        self.assertIsNotNone(clean_offset)
        self.assertEqual(clean_limit, limit)
Example #14
0
    def test_offset_as_none(self):
        """ When Offset is set to None it should use an offset of 0 """
        limit = self.CONF.default_limit_paging
        clean_offset, clean_limit = clean_paging_values(offset_arg=None,
                                                        limit_arg=limit)

        self.assertIsNotNone(clean_offset)
        self.assertEqual(clean_limit, limit)
Example #15
0
    def test_limit_as_none(self):
        """When Limit is set to None it should use the default limit."""
        offset = 0
        clean_offset, clean_limit = repositories.clean_paging_values(
            offset_arg=offset, limit_arg=None)

        self.assertEqual(clean_offset, offset)
        self.assertEqual(self.default_limit, clean_limit)
Example #16
0
    def test_limit_as_none(self):
        """ When Limit is set to None it should use the default limit"""
        offset = 0
        clean_offset, clean_limit = clean_paging_values(offset_arg=offset,
                                                        limit_arg=None)

        self.assertEqual(clean_offset, offset)
        self.assertIsNotNone(clean_limit)
Example #17
0
    def test_limit_as_none(self):
        """ When Limit is set to None it should use the default limit"""
        offset = 0
        clean_offset, clean_limit = clean_paging_values(offset_arg=offset,
                                                        limit_arg=None)

        self.assertEqual(clean_offset, offset)
        self.assertIsNotNone(clean_limit)
Example #18
0
 def test_limit_is_less_than_one(self):
     """Offset should default to 1."""
     limit = -1
     clean_offset, clean_limit = repositories.clean_paging_values(
         offset_arg=1,
         limit_arg=limit)
     self.assertEqual(1, clean_offset)
     self.assertEqual(1, clean_limit)
Example #19
0
    def test_offset_as_none(self):
        """When Offset is set to None it should use an offset of 0."""
        clean_offset, clean_limit = repositories.clean_paging_values(
            offset_arg=None,
            limit_arg=self.default_limit)

        self.assertEqual(0, clean_offset)
        self.assertEqual(self.default_limit, clean_limit)
Example #20
0
    def test_limit_as_none(self):
        """When Limit is set to None it should use the default limit."""
        offset = 0
        clean_offset, clean_limit = repositories.clean_paging_values(
            offset_arg=offset,
            limit_arg=None)

        self.assertEqual(offset, clean_offset)
        self.assertEqual(self.default_limit, clean_limit)
Example #21
0
 def test_limit_as_uncastable_str(self):
     """ When Limit cannot be cast to an int, expect the default """
     clean_offset, clean_limit = clean_paging_values(offset_arg=0,
                                                     limit_arg='boom')
     self.assertEqual(clean_offset, 0)
     self.assertEqual(clean_limit, self.CONF.default_limit_paging)
Example #22
0
 def test_limit_ist_too_big(self):
     """Limit should max out at configured value"""
     limit = self.CONF.max_limit_paging + 10
     clean_offset, clean_limit = clean_paging_values(offset_arg=1,
                                                     limit_arg=limit)
     self.assertEqual(clean_limit, self.CONF.max_limit_paging)
Example #23
0
    def test_parameters_not_assigned(self):
        """The cleaner should use defaults when params are not specified."""
        clean_offset, clean_limit = repositories.clean_paging_values()

        self.assertEqual(clean_offset, 0)
        self.assertEqual(clean_limit, self.CONF.default_limit_paging)
Example #24
0
    def test_parameters_not_assigned(self):
        """The cleaner should use defaults when params are not specified."""
        clean_offset, clean_limit = repositories.clean_paging_values()

        self.assertEqual(clean_offset, 0)
        self.assertEqual(self.default_limit, clean_limit)