コード例 #1
0
    def test_new_project(self):
        rest = _RestProxyForTest()
        projects = Projects(rest)

        expected_data = {}

        def check_input(data_dict):
            self.assertEqual(expected_data, data_dict)
            return True

        expected_data = {'parent': None, 'name': None, 'description': None}
        rest.expect_post("/project", check_input, 200, {'uuid': 'aaa'})
        project = projects.new_project(None, None, None)
        self.assertEqual("aaa", project.get_uuid())
        self.assertEqual(None, project.get_parent())
        self.assertEqual(None, project.get_name())
        self.assertEqual(None, project.get_description())

        expected_data = {'parent': 'ppp', 'name': 'nnn', 'description': 'ddd'}
        rest.expect_post("/project", check_input, 200, {'uuid': 'ccc'})
        project = projects.new_project('ppp', 'nnn', 'ddd')
        self.assertEqual("ccc", project.get_uuid())
        self.assertEqual('ppp', project.get_parent())
        self.assertEqual('nnn', project.get_name())
        self.assertEqual('ddd', project.get_description())

        rest.expect_post("/project", check_input, 404, {})
        with self.assertRaises(RuntimeError):
            project = projects.new_project('ppp', 'nnn', 'ddd')
コード例 #2
0
            with open(tokenFile, "w") as f:
                f.write(auth.get_token())
except RuntimeError as e:
    print('Encountered server error while attempting to authorize: ' + str(e))

if auth.get_token() == "":
    print('Could not authorize user.')
else:
    print('Welcome, ' + auth.get_user())

# auth.get_token() can now be used to authorize calls to other API methods.
auth_rest = AuthorizingRestProxy(rest, auth.get_token())

# Get projects TODO: move this somewhere else
projects = Projects(auth_rest)
project = projects.new_project('ffffffff-ffff-ffff-ffff-ffffffffffff', None,
                               "parent")
child = projects.new_project(project.get_uuid(), None, "child")
print('Current projects, including newly-created parent and child:')
projects.print_projects()
projects.delete_project(child.get_uuid())
projects.delete_project(project.get_uuid())

# Example inputs

# 6x1 state vector (position [km], velocity [km/s])
state_vec = [
    130347560.13690618, -74407287.6018632, -35247598.541470632,
    23.935241263310683, 27.146279819258538, 10.346605942591514
]

# Lower triangular covariance matrix (21 elements in a list)