Beispiel #1
0
    def no_test_whoami(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';

        client = MHHTTPClient(server, user, password)
        mh_user = client.welcome()

        self.assertTrue(True)
Beispiel #2
0
    def no_test_whoami(self):
        server = 'http://demo.opencastproject.org'
        user = '******'
        password = '******'

        client = MHHTTPClient(server, user, password)
        mh_user = client.welcome()

        self.assertTrue(True)
Beispiel #3
0
    def no_test_whoami(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';

        client = MHHTTPClient(server, user, password)
        mh_user = client.whoami()

        self.assertEqual(mh_user['username'], 'matterhorn_system_account')
Beispiel #4
0
    def no_test_whoami(self):
        server = 'http://demo.opencastproject.org'
        user = '******'
        password = '******'

        client = MHHTTPClient(server, user, password)
        mh_user = client.whoami()

        self.assertEqual(mh_user['username'], 'matterhorn_system_account')
Beispiel #5
0
    def no_test_series(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';

        client = MHHTTPClient(server, user, password)
        series = client.getseries()    

        self.assertTrue(isinstance(series, basestring))
        self.assertTrue(isinstance(json.loads(series), dict))
Beispiel #6
0
    def no_test_series(self):
        server = 'http://demo.opencastproject.org'
        user = '******'
        password = '******'

        client = MHHTTPClient(server, user, password)
        series = client.getseries()

        self.assertTrue(isinstance(series, basestring))
        self.assertTrue(isinstance(json.loads(series), dict))
Beispiel #7
0
    def no_test_prepare_ingest(self):
        workflow = 'mini-full'
        workflow_parameters = {'uno': 'uno', 'dos': 'dos'}
        client = MHHTTPClient(None, None, None, None, None, workflow, workflow_parameters)
        
        # Default values
        postdict = client._prepare_ingest('file')
        self.assertEqual(postdict, {'workflowDefinitionId': 'mini-full', 'track': (pycurl.FORM_FILE, 'file'),
                                    'uno': 'uno', 'dos': 'dos'})

        # Other workflow
        postdict = client._prepare_ingest('file', 'other-workflow')
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'uno': 'uno', 'dos': 'dos'})

        # With workflow_instance
        postdict = client._prepare_ingest('file', 'other-workflow', 342)
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'workflowInstanceId': '342', 'uno': 'uno', 'dos': 'dos'})

        # Other workflow_parameters
        postdict = client._prepare_ingest('file', workflow='other-workflow', workflow_parameters={'diezuno': 'diez'})
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'diezuno': 'diez'})

        # Other workflow_parameters as string
        postdict = client._prepare_ingest('file', workflow='other-workflow', workflow_parameters='diezdos:8)')
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'diezdos': '8)'})

        # All diferent
        postdict = client._prepare_ingest('file', 'other-workflow', 1342, {'param': 'false', 'param2': 'true'})
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'workflowInstanceId': '1342', 'param': 'false', 'param2': 'true'})
Beispiel #8
0
    def no_test_setcapabilities(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'

        client = MHHTTPClient(server, user, password)
        client.hostname = client_name
        client.address = client_address
        
        out = parseString(client.setconfiguration({}))
        for item  in out.getElementsByTagName('item'):
            if item.getAttribute('key') == 'service.pid':
                self.assertEqual(item.firstChild.firstChild.wholeText, 'galicaster')
Beispiel #9
0
    def no_test_setstate(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'
        client_states = [ 'shutting_down', 'capturing', 'uploading', 'unknown', 'idle' ]        

        client = MHHTTPClient(server, user, password)
        client.hostname = client_name
        client.address = client_address
        
        for state in client_states:
            a = client.setstate(state)
            self.assertEqual(a, '{0} set to {1}'.format(client_name, state))
Beispiel #10
0
    def no_test_setcapabilities(self):
        server = 'http://demo.opencastproject.org'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'

        client = MHHTTPClient(server, user, password)
        client.hostname = client_name
        client.address = client_address
        
        out = parseString(client.setconfiguration({}))
        for item  in out.getElementsByTagName('item'):
            if item.getAttribute('key') == 'service.pid':
                self.assertEqual(item.firstChild.firstChild.wholeText, 'galicaster')
Beispiel #11
0
    def no_test_setstate(self):
        server = 'http://demo.opencastproject.org'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'
        client_states = [ 'shutting_down', 'capturing', 'uploading', 'unknown', 'idle' ]        

        client = MHHTTPClient(server, user, password)
        client.hostname = client_name
        client.address = client_address
        
        for state in client_states:
            a = client.setstate(state)
            self.assertEqual(a, '{0} set to {1}'.format(client_name, state))
Beispiel #12
0
    def no_test_limit_init_duration(self):
        server = 'http://10.10.10.10:10'
        user = '******'
        password = '******'

        client = MHHTTPClient(server, user, password)

        self.assertRaises(RuntimeError, client.welcome)
Beispiel #13
0
    def no_test_prepare_ingest(self):
        workflow = 'mini-full'
        workflow_parameters = 'uno:uno;dos:dos'
        client = MHHTTPClient(None, None, None, None, None, workflow, workflow_parameters)
        
        # Default values
        postdict = client._prepare_ingest('file')
        self.assertEqual(postdict, {'workflowDefinitionId': 'mini-full', 'track': (pycurl.FORM_FILE, 'file'),
                                    'uno': 'uno', 'dos': 'dos'})

        # Other workflow
        postdict = client._prepare_ingest('file', 'other-workflow')
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'uno': 'uno', 'dos': 'dos'})

        # With workflow_instance
        postdict = client._prepare_ingest('file', 'other-workflow', 342)
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'workflowInstanceId': '342', 'uno': 'uno', 'dos': 'dos'})

        # Other workflow_parameters
        postdict = client._prepare_ingest('file', workflow='other-workflow', workflow_parameters={'diezuno': 'diez'})
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'diezuno': 'diez'})

        # Other workflow_parameters as string
        postdict = client._prepare_ingest('file', workflow='other-workflow', workflow_parameters='diezdos:8)')
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'diezdos': '8)'})

        # All diferent
        postdict = client._prepare_ingest('file', 'other-workflow', 1342, {'param': 'false', 'param2': 'true'})
        self.assertEqual(postdict, {'workflowDefinitionId': 'other-workflow', 'track': (pycurl.FORM_FILE, 'file'),
                                    'workflowInstanceId': '1342', 'param': 'false', 'param2': 'true'})
Beispiel #14
0
    def no_test_userandaddressinit(self):
        server = 'http://demo.opencastproject.org'
        user = '******';
        password = '******';
        hostname = 'rubenruaHost'
        address = '8.8.8.8'
        workflow = 'mini-full'
        workflow_parameters = {'uno': 'uno'}
        workflow_parameters_2 = {'uno': 'uno', 'dos': 'dos'}

        client = MHHTTPClient(server, user, password)
        self.assertEqual(client.hostname, 'galicaster')
        self.assertEqual(client.address, socket.gethostbyname(socket.gethostname()))

        client = MHHTTPClient(server, user, password, hostname)
        self.assertEqual(client.hostname, hostname)
        self.assertEqual(client.address, socket.gethostbyname(socket.gethostname()))

        client = MHHTTPClient(server, user, password, hostname, address)
        self.assertEqual(client.hostname, hostname)
        self.assertEqual(client.address, address)

        client = MHHTTPClient(server, user, password, hostname, address)
        self.assertEqual(client.workflow, 'full')
        self.assertEqual(client.workflow_parameters, {'trimHold': 'true'})

        client = MHHTTPClient(server, user, password, hostname, address, workflow, workflow_parameters)
        self.assertEqual(client.workflow, 'mini-full')
        self.assertEqual(client.workflow_parameters, workflow_parameters)

        client = MHHTTPClient(server, user, password, hostname, address, workflow, workflow_parameters_2)
        self.assertEqual(client.workflow, 'mini-full')
        self.assertEqual(client.workflow_parameters, workflow_parameters_2)
Beispiel #15
0
def get_mhclient():
    """
    Get the Mhclient class from the App Context
    """
    if 'mhclient' not in __galicaster_context:
        conf = get_conf()
        if get_conf().get_boolean("ingest", "active"):
            mhclient = MHHTTPClient(conf.get('ingest', 'host'),
                                    conf.get('ingest', 'username'),
                                    conf.get('ingest',
                                             'password'), conf.hostname,
                                    conf.get('ingest', 'address'),
                                    conf.get('ingest', 'workflow'),
                                    conf.get('ingest', 'workflow-parameters'))
        else:
            mhclient = None
        __galicaster_context['mhclient'] = mhclient

    return __galicaster_context['mhclient']
Beispiel #16
0
def get_mhclient():
    """
    Get the Mhclient class from the App Context
    """
    if 'mhclient' not in __galicaster_context:
        conf = get_conf()
        multiple_ingest = conf.get_boolean('ingest',
                                           'multiple-ingest') or False
        connect_timeout = conf.get_int('ingest', 'connect_timeout') or 2
        timeout = conf.get_int('ingest', 'timeout') or 2
        if get_conf().get_boolean("ingest", "active"):
            mhclient = MHHTTPClient(
                conf.get('ingest', 'host'), conf.get('ingest', 'username'),
                conf.get('ingest', 'password'), conf.hostname,
                conf.get('ingest', 'address'), multiple_ingest,
                connect_timeout, timeout, conf.get('ingest', 'workflow'),
                conf.get_dict('ingest', 'workflow-parameters'),
                conf.get_dict('ingest', 'ca-parameters'), get_repository(),
                get_logger())
        else:
            mhclient = None
        __galicaster_context['mhclient'] = mhclient

    return __galicaster_context['mhclient']