예제 #1
0
    def test_duplicate_name(self, load, is_valid_cube):
        cube1 = Mock(**{"name.return_value": "foo"})
        cube2 = Mock(**{"name.return_value": "foo"})
        load.return_value = [cube1, cube2]
        is_valid_cube.return_value = True

        result = gridded_forecast._load(sentinel.pattern)

        load.assert_called_once_with(sentinel.pattern)
        self.assertEqual(is_valid_cube.mock_calls, [call(cube1), call(cube2)])
        self.assertEqual(result, {"foo (1)": cube1, "foo (2)": cube2})
예제 #2
0
    def test_all_unique(self, load, is_valid_cube):
        cube1 = Mock(**{'name.return_value': 'foo'})
        cube2 = Mock(**{'name.return_value': 'bar'})
        load.return_value = [cube1, cube2]
        is_valid_cube.return_value = True

        result = gridded_forecast._load(sentinel.pattern)

        load.assert_called_once_with(sentinel.pattern)
        self.assertEqual(is_valid_cube.mock_calls, [call(cube1), call(cube2)])
        self.assertEqual(result, {'foo': cube1, 'bar': cube2})
예제 #3
0
    def test_none_valid(self, load, is_valid_cube):
        load.return_value = ["foo", "bar"]
        is_valid_cube.return_value = False

        with self.assertRaises(AssertionError):
            gridded_forecast._load(None)
예제 #4
0
 def image_loader(self):
     cube_dict = _load(self._paths, is_valid_cube)
     return ImageLoader(self._label, cube_dict, extract_cube=extract_cube)
예제 #5
0
 def navigator(self):
     """Construct a Navigator"""
     cube_dict = _load(self._paths, is_valid_cube)
     return Navigator(cube_dict)