Exemple #1
0
    def test_is_not_ready(self):
        """Test when a job is not ready

        This function tests that a job will correctly indicate when it is not ready and returns the expected number of
        ephemeris parts count.

        """

        # Dummy UUID for testing
        uuid = 'BLAH'

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' request with calc_state as 'RUNNING'
        rest.expect_get(self._base + '/batch/' + uuid, 200, {
            'calc_state': 'RUNNING',
            'parts_count': 5
        })

        # Initiate Batch class
        batch = Batch()

        # Set UUID
        batch._uuid = uuid

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

        # Assert that checking if the batch is ready will return False
        self.assertFalse(batch.is_ready())

        # Assert that the number of expected parts is returned
        self.assertEqual(batch.get_parts_count(), 5)
Exemple #2
0
    def test_is_ready_failed(self):
        """Test that job is ready when failed

        This function tests that a job will indicate that it is ready if it has failed.

        """

        # Dummy UUID for testing
        uuid = 'BLAH'

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' request with calc_state as 'FAILED'
        rest.expect_get(
            self._base + '/batch/' + uuid, 200, {
                'calc_state': 'FAILED',
                'parts_count': 42,
                'summary': "ZQZ",
                'error': 'No error!'
            })

        # Initiate Batch class
        batch = Batch()

        # Set UUID
        batch._uuid = uuid

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

        # Assert that checking if the batch is ready will return True
        self.assertTrue(batch.is_ready())

        # Assert that the calc state is as expected
        self.assertEqual(batch.get_calc_state(), 'FAILED')

        # Assert that the number of expected parts is returned
        self.assertEqual(batch.get_parts_count(), 42)
    def test_is_ready_completed(self):
        """Test that job is ready when completed

        This function tests that a job will indicate that it is ready if it has completed.

        """

        # Dummy UUID for testing
        uuid = 'BLAH'

        # Use REST proxy for testing
        rest = _RestProxyForTest()

        # Set expected 'GET' request with calc_state as 'COMPLETED'
        rest.expect_get(
            '/batch/' + uuid, 200, {
                'uuid': uuid,
                'calc_state': 'COMPLETED',
                'parts_count': 42,
                'summary': "ZQZ",
                'error': 'No error!'
            })

        # Initiate Batch class
        batch = Batch(rest)

        # Set UUID
        batch.set_uuid_for_testing(uuid)

        # Assert that checking if the batch is ready will return True
        self.assertTrue(batch.is_ready())

        # Assert that the calc state is as expected
        self.assertEqual(batch.get_calc_state(), 'COMPLETED')

        # Assert that the number of expected parts is returned
        self.assertEqual(batch.get_parts_count(), 42)
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)