示例#1
0
    def test_get_ephemeris(self):
        """Test that an ephemeris is returned if the job has completed successfully

        This function tests that a job that is completed successfully will return the expected ephemeris.

        """

        # Dummy UUID and part number for testing
        uuid = 'BLAH'
        part = 3

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' request with calc_state as 'COMPLETED' for specific part
        rest.expect_get(
            self._base + '/batch/' + uuid + '/' + str(part), 200, {
                'calc_state': 'COMPLETED',
                'error': 'No error!',
                'stk_ephemeris': 'something',
                'part_index': part
            })

        # Initiate Batch class
        batch = Batch()

        # Set UUID, parts count, and overall calc state (as 'COMPLETED')
        batch._uuid = uuid
        batch._parts_count = 10
        batch._calc_state = 'COMPLETED'

        # Override network access with proxy
        batch.set_rest_accessor(rest)

        # Assert that an overall calc state as 'COMPLETED' will return the expected ephemeris
        self.assertEqual(batch.get_part_ephemeris(part), 'something')

        # Assert that the error is as expected
        self.assertEqual(batch.get_part_error(part), 'No error!')

        # Assert that the calc state for the specific part's run is as expected
        self.assertEqual(batch.get_part_state(part), 'COMPLETED')

        # Assert that checking if the part is ready will return True
        self.assertTrue(batch.is_ready_part(part))
示例#2
0
    def test_is_ready_failed_part(self):
        """Test when an individual part has failed

        This function tests that a job will correctly indicate when a part has failed, that it returns the expected
        error, and that it returns None for ephemeris.

        """

        # Dummy UUID and part number for testing
        uuid = 'BLAH'
        part = 3

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' request with calc_state as 'FAILED'
        rest.expect_get(self._base + '/batch/' + uuid + '/' + str(part), 200, {
            'calc_state': 'FAILED',
            'error': 'Some error',
            'part_index': part
        })

        # Initiate Batch class
        batch = Batch()

        # Set UUID, parts count, and overall calc state (as 'FAILED')
        batch._uuid = uuid
        batch._parts_count = 10
        batch._calc_state = 'FAILED'

        # Override network access with proxy
        batch.set_rest_accessor(rest)

        # Assert that the calc state for the specific part's run is as expected
        self.assertEqual(batch.get_part_state(part), 'FAILED')

        # Assert that the error returned is as expected
        self.assertEqual(batch.get_part_error(part), 'Some error')

        # Assert that attempting to retrieve a part's ephemeris will return None
        self.assertEqual(batch.get_part_ephemeris(part), None)
示例#3
0
    def test_is_ready_failed_part(self):
        """Test when an individual part has failed

        This function tests that a job will correctly indicate when a part has failed, that it returns the expected
        error, and that it returns None for ephemeris.

        """

        # Dummy UUID and part number for testing
        uuid = 'BLAH'
        part = 3
        num_parts = 10

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' requests with calc_state as 'FAILED'
        for i in range(1, num_parts + 1):
            rest.expect_get('/batch/' + uuid + '/' + str(i), 200, {
                'calc_state': 'FAILED',
                'error': 'Some error',
                'part_index': i
            })

        # Initiate Batch class
        batch = Batch(rest)

        # Set UUID, parts count, and overall calc state (as 'FAILED')
        batch.set_uuid_for_testing(uuid)
        batch.set_parts_count_for_testing(num_parts)
        batch.set_calc_state_for_testing('FAILED')

        # Assert that the calc state for the specific part's run is as expected
        self.assertEqual(batch.get_part_state(part), 'FAILED')

        # Assert that the error returned is as expected
        self.assertEqual(batch.get_part_error(part), 'Some error')

        # Assert that attempting to retrieve a part's ephemeris will return None
        self.assertEqual(batch.get_part_ephemeris(part), None)