Exemplo n.º 1
0
    def test_whoami(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

        client = OCHTTPClient(server, user, password)
        oc_user = client.whoami()

        self.assertEqual(oc_user['username'], 'opencast_system_account')
Exemplo n.º 2
0
    def test_whoami(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

        client = OCHTTPClient(server, user, password)
        oc_user = client.welcome()

        self.assertTrue(True)
Exemplo n.º 3
0
    def test_whoami(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

        client = OCHTTPClient(server, user, password)
        oc_user = client.welcome()

        self.assertTrue(True)
Exemplo n.º 4
0
    def test_whoami(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

        client = OCHTTPClient(server, user, password)
        oc_user = client.whoami()

        self.assertEqual(oc_user['username'], 'opencast_system_account')
Exemplo n.º 5
0
    def test_series(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

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

        self.assertTrue(isinstance(series, basestring))
        self.assertTrue(isinstance(json.loads(series), dict))
Exemplo n.º 6
0
    def test_series(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'

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

        self.assertTrue(isinstance(series, basestring))
        self.assertTrue(isinstance(json.loads(series), dict))
Exemplo n.º 7
0
    def test_setcapabilities(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'

        client = OCHTTPClient(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')
Exemplo n.º 8
0
    def test_setstate(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'
        client_states = [ 'shutting_down', 'capturing', 'uploading', 'unknown', 'idle' ]        

        client = OCHTTPClient(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))
Exemplo n.º 9
0
    def test_setcapabilities(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'

        client = OCHTTPClient(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')
Exemplo n.º 10
0
def get_occlient():
    """Creates if necessary and retrieves the OCclient class from the App Context.
    Returns:
        OCHTTPClient: the opencast client of galicaster context.
    """
    from galicaster.opencast.client import OCHTTPClient

    if 'occlient' 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"):
            occlient = OCHTTPClient(
                conf.get('ingest', 'host'), conf.get('ingest', 'username'),
                conf.get('ingest', 'password'), conf.get_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'),
                conf.get('heartbeat', 'short'), conf.get('heartbeat', 'long'),
                get_repository(), get_logger())
        else:
            occlient = None
        __galicaster_context['occlient'] = occlient

    return __galicaster_context['occlient']
Exemplo n.º 11
0
    def test_limit_init_duration(self):
        server = 'http://10.10.10.10:10'
        user = '******'
        password = '******'

        client = OCHTTPClient(server, user, password)

        self.assertRaises(RuntimeError, client.welcome)
Exemplo n.º 12
0
    def test_setstate(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'
        client_name = 'rubenrua_pr'
        client_address = '172.20.209.225'
        client_states = [
            'shutting_down', 'capturing', 'uploading', 'unknown', 'idle'
        ]

        client = OCHTTPClient(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))
Exemplo n.º 13
0
    def test_prepare_ingest(self):
        workflow = 'mini-full'
        workflow_parameters = {'uno': 'uno', 'dos': 'dos'}
        client = OCHTTPClient(None, None, None, None, None, False, 2, 2, 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'})
Exemplo n.º 14
0
    def test_init(self):
        server = 'http://demo.opencastproject.org:8080'
        user = '******'
        password = '******'
        hostname = 'GalicasterTestHost'
        address = '8.8.8.8'
        multiple_ingest = False
        connect_timeout = 2
        timeout = 2
        workflow = 'mini-full'
        workflow_parameters = {'uno': 'uno'}
        workflow_parameters_2 = {'uno': 'uno', 'dos': 'dos'}

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

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

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

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

        client = OCHTTPClient(server, user, password, hostname, address,
                              multiple_ingest, connect_timeout, timeout)
        self.assertEqual(client.multiple_ingest, multiple_ingest)
        self.assertEqual(client.connect_timeout, connect_timeout)
        self.assertEqual(client.timeout, timeout)

        client = OCHTTPClient(server, user, password, hostname, address,
                              multiple_ingest, connect_timeout, timeout,
                              workflow, workflow_parameters)
        self.assertEqual(client.workflow, 'mini-full')
        self.assertEqual(client.workflow_parameters, workflow_parameters)

        client = OCHTTPClient(server, user, password, hostname, address,
                              multiple_ingest, connect_timeout, timeout,
                              workflow, workflow_parameters_2)
        self.assertEqual(client.workflow, 'mini-full')
        self.assertEqual(client.workflow_parameters, workflow_parameters_2)
Exemplo n.º 15
0
    def test_prepare_ingest(self):
        workflow = 'mini-full'
        workflow_parameters = {'uno': 'uno', 'dos': 'dos'}
        client = OCHTTPClient(None, None, None, None, None, False, 2, 2,
                              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'
            })