Exemple #1
0
 def test_project_methods(self):
     """Integration test for project related calls."""
     # Add test project to boinc client
     self.boinc_rpc.project_attach(self.url, self.auth)
     # Check that added project is present
     status = self.boinc_rpc.simple_request('get_project_status')
     result = et_find(ET.fromstring(status), 'master_url')
     self.assertEqual(result.text, self.url)
     # Remove test project from boinc client
     self.boinc_rpc.project_command(self.url, 'detach')
     # Check that test project has been removed
     status = self.boinc_rpc.simple_request('get_project_status')
     result = et_find(ET.fromstring(status), 'master_url')
     self.assertEqual(result, None)
Exemple #2
0
def main():
    """ Main Function. Intended to run from command line"""
    parser = get_parser()
    args = parser.parse_args()
    host = DEFAULT_HOST
    port = DEFAULT_PORT
    if args.host:
        host_port = args.host.partition(':')  # ('host', ':', 'port')
        host = host_port[0]
        if host_port[2].isdigit():
            port = host_port[2]
    if args.passwd:
        password = args.passwd
    else:
        password = get_password()
    try:
        req = BoincRpc(host, port, password)
        if args.get_host_info:
            print_xml(req.simple_request('get_host_info'))
        if args.client_version:
            print_xml(req.simple_request('exchange_versions'))
        if args.get_state:
            print_xml(req.simple_request('get_state'))
        if args.acct_mgr_info:
            print_xml(req.simple_request('acct_mgr_info'))
        if args.get_project_status:
            print_xml(req.simple_request('get_project_status'))
        if args.acct_mgr_attach:
            url, name, input_pwd = args.acct_mgr_attach
            print_xml(req.acct_mgr_attach(url, name, input_pwd))
        if args.lookup_account:
            url, email, input_pwd = args.lookup_account
            response = req.lookup_account(url, email, input_pwd)
            print_xml(response)
        if args.project_attach:
            url, auth = args.project_attach
            response = ET.fromstring(req.project_attach(url, auth))
            error = et_find(response, 'error_num')
            if error is not None and error.text == '0':
                print('Success')
            else:
                print_xml(response)
        if args.project:
            url, command = args.project
            if command not in PROJECT_CHOICES:
                sys.exit('Error: Illegal op value. Possible op values: ' +
                         str(PROJECT_CHOICES))
            print_xml(req.project_command(url, command))
    except BoincRpcError as exception:
        sys.exit('Error: ' + str(exception))
Exemple #3
0
 def test_simple_request(self):
     """ Check that response contains meaningful result."""
     exchange_versions = self.boinc_rpc.simple_request('exchange_versions')
     result = et_find(ET.fromstring(exchange_versions), 'major')
     # Check that respone contains some info
     self.assertEqual(result.tag, 'major')
Exemple #4
0
 def test_et_find_none(self):
     """Case when target is missing in xml."""
     result = et_find(self.sample, 'three')
     self.assertEqual(result, None)
Exemple #5
0
 def test_et_find_two_and_two(self):
     """Case when target not in the first layer."""
     result = et_find(self.sample, 'two_and_five')
     self.assertEqual(result.text, '2.5')
Exemple #6
0
 def test_et_find_two(self):
     """Case when target tag contains additional objects."""
     result = et_find(self.sample, 'two')
     self.assertEqual(result.text, '2')
Exemple #7
0
 def test_et_find_one(self):
     """Simplest case when the target is in the first layer of xml."""
     result = et_find(self.sample, 'one')
     self.assertEqual(result.text, '1')