示例#1
0
    def test_create_extent_dict(self):
        test = ('-te 5 60 6 61.1 -ts 500 500',
                '-te -92.08 26.85 -92.00 26.91 -ts 200 200', '-te 5 60 6 61.1',
                '-te 5 60 6 61.1 -te 5 60 6 61.1')
        output_1 = {'te': [5., 60., 6., 61.1], 'ts': [500, 500]}
        output_2 = {'te': [-92.08, 26.85, -92.00, 26.91], 'ts': [200, 200]}
        result_1 = Domain._create_extent_dict(test[0])
        self.assertIsInstance(result_1, dict)
        self.assertEqual(len(list(result_1.keys())), 2)
        self.assertEqual(result_1, output_1)
        result_2 = Domain._create_extent_dict(test[1])
        self.assertEquals(result_2, output_2)
        with self.assertRaises(ValueError) as opt_err:
            Domain._create_extent_dict(test[2])
            self.assertEquals(
                opt_err.args[0],
                '<extent_dict> must contains exactly 2 parameters ')
        self.assertEqual(result_2, output_2)

        try:
            test = Domain._create_extent_dict(test[2])
        except ValueError as opt_err:
            self.assertEqual(
                opt_err.args[0],
                '<extent_dict> must contains exactly 2 parameters '
                '("-te" or "-lle") and ("-ts" or "-tr")')
        with self.assertRaises(ValueError) as opt_err:
            Domain._create_extent_dict(test[3])
            self.assertEquals(
                opt_err.args[0],
                '<extent_dict> must contains exactly 2 parameters '
                '("-te" or "-lle") and ("-ts" or "-tr")')
示例#2
0
    def test_create_extent_dict(self):
        test = ('-te 5 60 6 61.1 -ts 500 500',
                '-te -92.08 26.85 -92.00 26.91 -ts 200 200',
                '-te 5 60 6 61.1',
                '-te 5 60 6 61.1 -te 5 60 6 61.1')
        output_1 = {'te': [5., 60., 6., 61.1], 'ts': [500, 500]}
        output_2 = {'te': [-92.08, 26.85, -92.00, 26.91], 'ts': [200, 200]}
        result_1 = Domain._create_extent_dict(test[0])
        self.assertIsInstance(result_1, dict)
        self.assertEqual(len(list(result_1.keys())), 2)
        self.assertEqual(result_1, output_1)
        result_2 = Domain._create_extent_dict(test[1])
        self.assertEquals(result_2, output_2)
        with self.assertRaises(ValueError) as opt_err:
            Domain._create_extent_dict(test[2])
            self.assertEquals(opt_err.args[0], '<extent_dict> must contains exactly 2 parameters ')
        self.assertEqual(result_2, output_2)

        try:
            test = Domain._create_extent_dict(test[2])
        except ValueError as opt_err:
            self.assertEqual(opt_err.args[0], '<extent_dict> must contains exactly 2 parameters '
                                               '("-te" or "-lle") and ("-ts" or "-tr")')
        with self.assertRaises(ValueError) as opt_err:
            Domain._create_extent_dict(test[3])
            self.assertEquals(opt_err.args[0], '<extent_dict> must contains exactly 2 parameters '
                                               '("-te" or "-lle") and ("-ts" or "-tr")')