コード例 #1
0
    def test_validate_bbox_params(self):

        data = {
            'xmin': self.extents[0],
            'ymin': self.extents[1],
            'xmax': self.extents[2],
            'ymax': self.extents[3]
        }

        (xmin, ymin, xmax, ymax) = validate_bbox_params(data)
        self.assertEqual(xmin, data['xmin'])
        self.assertEqual(ymin, data['ymin'])
        self.assertEqual(xmax, data['xmax'])
        self.assertEqual(ymax, data['ymax'])

        data = {'xmin': 1, 'ymin': -1, 'xmax': -1, 'ymax': 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {'xmin': -1, 'ymin': 1, 'xmax': 1, 'ymax': -1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {'xmin': -181, 'ymin': -1, 'xmax': 1, 'ymax': 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {'xmin': -1, 'ymin': -91, 'xmax': 1, 'ymax': 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)
コード例 #2
0
    def test_validate_bbox_params(self):

        data = {
            "xmin": self.extents[0],
            "ymin": self.extents[1],
            "xmax": self.extents[2],
            "ymax": self.extents[3]
        }

        (xmin, ymin, xmax, ymax) = validate_bbox_params(data)
        self.assertEqual(xmin, data["xmin"])
        self.assertEqual(ymin, data["ymin"])
        self.assertEqual(xmax, data["xmax"])
        self.assertEqual(ymax, data["ymax"])

        data = {"xmin": 1, "ymin": -1, "xmax": -1, "ymax": 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {"xmin": -1, "ymin": 1, "xmax": 1, "ymax": -1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {"xmin": -181, "ymin": -1, "xmax": 1, "ymax": 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)

        data = {"xmin": -1, "ymin": -91, "xmax": 1, "ymax": 1}
        with self.assertRaises(ValidationError):
            validate_bbox_params(data)