示例#1
0
    def setUp(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 3

        def mock_hdulist():
            return MagicMock(spec=HDUList)

        grid = CutoutGrid(source)
        self.hdulist00 = mock_hdulist()
        self.hdulist01 = mock_hdulist()
        self.hdulist02 = mock_hdulist()
        self.hdulist10 = mock_hdulist()
        self.hdulist11 = mock_hdulist()
        self.hdulist12 = mock_hdulist()
        self.hdulist20 = mock_hdulist()
        self.hdulist21 = mock_hdulist()
        self.hdulist22 = mock_hdulist()

        def mock_cutout(hdulist):
            cutout = Mock(spec=SourceCutout)
            cutout.hdulist = hdulist
            return cutout

        grid.add_cutout(mock_cutout(self.hdulist00), 0, 0)
        grid.add_cutout(mock_cutout(self.hdulist01), 0, 1)
        grid.add_cutout(mock_cutout(self.hdulist02), 0, 2)
        grid.add_cutout(mock_cutout(self.hdulist10), 1, 0)
        grid.add_cutout(mock_cutout(self.hdulist11), 1, 1)
        grid.add_cutout(mock_cutout(self.hdulist12), 1, 2)
        grid.add_cutout(mock_cutout(self.hdulist20), 2, 0)
        grid.add_cutout(mock_cutout(self.hdulist21), 2, 1)
        grid.add_cutout(mock_cutout(self.hdulist22), 2, 2)

        self.grid = grid
示例#2
0
    def setUp(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 3

        def mock_hdulist():
            return MagicMock(spec=HDUList)

        grid = CutoutGrid(source)
        self.hdulist00 = mock_hdulist()
        self.hdulist01 = mock_hdulist()
        self.hdulist02 = mock_hdulist()
        self.hdulist10 = mock_hdulist()
        self.hdulist11 = mock_hdulist()
        self.hdulist12 = mock_hdulist()
        self.hdulist20 = mock_hdulist()
        self.hdulist21 = mock_hdulist()
        self.hdulist22 = mock_hdulist()

        def mock_cutout(hdulist):
            cutout = Mock(spec=SourceCutout)
            cutout.hdulist = hdulist
            return cutout

        grid.add_cutout(mock_cutout(self.hdulist00), 0, 0)
        grid.add_cutout(mock_cutout(self.hdulist01), 0, 1)
        grid.add_cutout(mock_cutout(self.hdulist02), 0, 2)
        grid.add_cutout(mock_cutout(self.hdulist10), 1, 0)
        grid.add_cutout(mock_cutout(self.hdulist11), 1, 1)
        grid.add_cutout(mock_cutout(self.hdulist12), 1, 2)
        grid.add_cutout(mock_cutout(self.hdulist20), 2, 0)
        grid.add_cutout(mock_cutout(self.hdulist21), 2, 1)
        grid.add_cutout(mock_cutout(self.hdulist22), 2, 2)

        self.grid = grid
示例#3
0
文件: test_grid.py 项目: OSSOS/MOP
class CutoutGridPrefilledTest(unittest.TestCase):
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)

    def test_added_cutouts_in_correct_location(self):
        assert_that(self.grid.get_cutout(0, 0), equal_to(self.cutout00))
        assert_that(self.grid.get_cutout(0, 1), equal_to(self.cutout01))
        assert_that(self.grid.get_cutout(1, 0), equal_to(self.cutout10))
        assert_that(self.grid.get_cutout(1, 1), equal_to(self.cutout11))

    def test_apply_function(self):
        function = Mock()

        self.grid.apply(function)

        assert_that(function.call_args_list, contains(
            call(self.cutout00, 0, 0),
            call(self.cutout01, 0, 1),
            call(self.cutout10, 1, 0),
            call(self.cutout11, 1, 1)))

    def test_reset_source_location(self):
        self.grid.reset_source_location()

        self.cutout00.reset_source_location.called_once_with()
        self.cutout01.reset_source_location.called_once_with()
        self.cutout10.reset_source_location.called_once_with()
        self.cutout11.reset_source_location.called_once_with()
示例#4
0
文件: test_grid.py 项目: ijiraq/MOP
class CutoutGridPrefilledTest(unittest.TestCase):
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)

    def test_added_cutouts_in_correct_location(self):
        assert_that(self.grid.get_cutout(0, 0), equal_to(self.cutout00))
        assert_that(self.grid.get_cutout(0, 1), equal_to(self.cutout01))
        assert_that(self.grid.get_cutout(1, 0), equal_to(self.cutout10))
        assert_that(self.grid.get_cutout(1, 1), equal_to(self.cutout11))

    def test_apply_function(self):
        function = Mock()

        self.grid.apply(function)

        assert_that(
            function.call_args_list,
            contains(call(self.cutout00, 0, 0), call(self.cutout01, 0, 1),
                     call(self.cutout10, 1, 0), call(self.cutout11, 1, 1)))

    def test_reset_source_location(self):
        self.grid.reset_source_location()

        self.cutout00.reset_source_location.called_once_with()
        self.cutout01.reset_source_location.called_once_with()
        self.cutout10.reset_source_location.called_once_with()
        self.cutout11.reset_source_location.called_once_with()