Exemplo n.º 1
0
    def test_is_not_ready_part(self):
        """Test when an individual part is not ready

        This function tests that a job will correctly indicate when a part is not ready.

        """

        # 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 'RUNNING'
        rest.expect_get(self._base + '/batch/' + uuid + '/' + str(part), 200, {
            'calc_state': 'RUNNING',
            'part_index': part
        })

        # Initiate Batch class
        batch = Batch()

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

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

        # Assert that checking if the part is ready will return False
        self.assertFalse(batch.is_ready_part(part))
Exemplo n.º 2
0
    def test_is_not_ready_part(self):
        """Test when an individual part is not ready

        This function tests that a job will correctly indicate when a part is not ready.

        """

        # 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_states as 'RUNNING'
        for i in range(1, num_parts + 1):
            rest.expect_get('/batch/' + uuid + '/' + str(i), 200, {
                'calc_state': 'RUNNING',
                'part_index': i
            })

        # Initiate Batch class
        batch = Batch(rest)

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

        # Assert that checking if the part is ready will return False
        self.assertFalse(batch.is_ready_part(part))
Exemplo n.º 3
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))