Exemple #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))
Exemple #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)
    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)
Exemple #4
0
# Optional parameters (uncomment to use)
# batch_run.set_propagator_uuid("00000000-0000-0000-0000-000000000002")    # Only Sun as point mass, nothing else
# batch_run.set_step_size(3600, 'min')
# batch_run.set_mass(500.5)
# batch_run.set_solar_rad_area(25.2)
# batch_run.set_solar_rad_coeff(1.2)
# batch_run.set_drag_area(33.3)
# batch_run.set_drag_coeff(2.5)
# batch_run.set_originator('Robot')
# batch_run.set_object_name('TestObj')
# batch_run.set_object_id('test1234')
# batch_run.set_description('some description')

print("Initial state %s" % batch_run)
print
print(batch_run.generate_opm())
batch_run.submit()
print
print("Final state %s" % batch_run)

while not batch_run.is_ready():
    time.sleep(5)

part_count = batch_run.get_parts_count()
print("Final state %s, part count %s" %
      (batch_run.get_calc_state(), part_count))
eph = batch_run.get_part_ephemeris(1)
print("Ephemeris")
print(eph)
Exemple #5
0
print("\n")
print("Initial state: %s\n" % batch_run)
print
print("Submitted OPM:")
print(batch_run.generate_opm())
batch_run.submit()
print("\n")
print("Final state: %s" % batch_run)

# Wait until batch run is ready
while not batch_run.is_ready():
    print("Waiting...")
    time.sleep(5)

# Get final parts count
part_count = batch_run.get_parts_count()
print("Final state %s, part count %s\n" %
      (batch_run.get_calc_state(), part_count))

# Get ephemeris of specified part
part_to_get = 1
eph = batch_run.get_part_ephemeris(part_to_get)
print("Ephemeris:")
print(eph)

# Get the end state vector (uncomment to use)
#end_state_vector = batch_run.get_end_state_vector()
#print("State vector at the end of propagation:")
#print(end_state_vector)
#print("\n")