def test_dna(self):
        """test /dna route"""
        # submit parameters
        app = 'dna'
        url = misc.URL + '/confirm'
        dna = 'GATCACAGGTCTATCACCCTATTAACCACTCACGGGA'
        values = {'app': app, 'cid': '', 'dna': dna}
        (code, html) = misc.post(url, values)
        self.assertEqual(code, httplib.OK)
        self.assertIn("Execute simulation", html)
        loc = html.find("cid:")
        cid = html[loc + 4:loc + 10]
        # test if input file was written
        assert os.path.exists('user_data/guest/dna/' + cid + '/dna.in') == 1

        # submit for execution
        app = 'dna'
        url = misc.URL + '/execute'
        np = "1"
        values = {'app': app, 'cid': cid, 'np': np}
        (code, html) = misc.post(url, values)
        self.assertEqual(code, httplib.OK)
        # wait a second for scheduler to start job
        # this may need to be increased to 2 or 3 seconds
        time.sleep(1)
        # test if output file was written
        assert os.path.exists('user_data/guest/dna/' + cid + '/dna.out') == 1
Exemplo n.º 2
0
 def test_login_invalid(self):
     url = misc.URL + '/login'
     values = {'askjdfas': 'guest', 'passwd': 'guest'}
     response = misc.post(url, values)
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("failed", html)
Exemplo n.º 3
0
async def consume(ws):
    while True:
        logger.info('ready to receive msg')
        message = await ws.recv()
        logger.info('received: %s', message)
        job = json.loads(message)
        # call gateway to execute task
        url = 'http://%s:%s/%s' % (gateway['host'], gateway['port'],
                                   job['task'])
        if 'data' in job and job['data']:
            misc.post(url, job['data'])
        else:
            misc.get(url)
 def test_step0_exists(self):
     appname = APP
     url = misc.URL + '/app_exists/' + appname
     values = {'appname': appname}
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertNotIn("true", html)
Exemplo n.º 5
0
    def put_file(self, id, files):
        """
        Create files in the session with given id, where files is a
        dictionary of filename:content pairs, and content is a string
        or file-like object.

        INPUT::

        - ``id`` -- nonnegative integer
        - ``files`` -- dictionary
        
        EXAMPLES::

            >>> from client import TestClient; c = TestClient()

        First try to put a file into a session that doesn't exist::

            >>> c.put_file(0, {'foo.txt':'stuff'})
            Traceback (most recent call last):
            ...
            ValueError: unknown session 0

            >>> c.new_session()
            0
            >>> c.put_file(0, {'a/b/c.txt':'more stuff'})
            >>> c.get_file(0, 'a/b/c.txt')
            u'more stuff'
            
            >>> c.quit()
        """
        msg = post('%s/put_file/%s'%(self._url, id), files=files)
        m = json.loads(msg)
        if m['status'] == u'error':
            raise ValueError(str(m['data']))
 def test_step0(self):
     """enter app name"""
     url = misc.URL + '/addapp/step1'
     appname = APP
     values = {'appname': appname}
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("configure app", html)
Exemplo n.º 7
0
 def test_registration_valid(self):
     url = misc.URL + '/register'
     values = {
         'user': user,
         'password1': passwd,
         'password2': passwd,
         'email': '*****@*****.**'
     }
     (code, html) = misc.post(url, values)
     #print html
     self.assertEqual(code, httplib.OK)
     self.assertNotIn("failed", html)
 def test_step3(self):
     url = misc.URL + '/addapp/step4'
     appname = APP
     input_format = 'ini'
     # contents not used just for user to see
     # so just pass dummy string in
     values = {
         'input_format': input_format,
         'appname': appname,
         'contents': 'blah'
     }
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("assign html input types", html)
Exemplo n.º 9
0
    def execute(self, session_id, code):
        r"""
        INPUT:
        
        - ``session_id`` -- id of a session
        - ``code`` -- string

        OUTPUT:
        
        - cell_id -- execution id number
        - status message
        
        EXAMPLES::
        
            >>> from client import TestClient; c = TestClient()
            >>> c.new_session()
            0
            >>> c.wait(0)
            >>> c.new_session()
            1
            >>> c.wait(1)
            >>> c.execute(0, 'print(2+3)')
            (0, 'running')
            >>> c.execute(1, 'print(5*8)')
            (0, 'running')
            >>> c.wait(0)
            >>> c.cells(0)
            [{u'code': u'print(2+3)', u'cell_id': 0}]
            >>> c.output(0,0)
            [{u'output': u'5\n', u'modified_files': None, u'done': False, u'number': 0}, {u'output': None, u'modified_files': None, u'done': True, u'number': 1}]
            >>> c.wait(1)
            >>> c.cells(1)
            [{u'code': u'print(5*8)', u'cell_id': 0}]
            >>> c.output(1,0)
            [{u'output': u'40\n', u'modified_files': None, u'done': False, u'number': 0}, {u'output': None, u'modified_files': None, u'done': True, u'number': 1}]
            >>> c.quit()            
        """
        msg = post('%s/execute/%s'%(self._url, session_id), {'code':code})
        m = json.loads(msg)
        if m['status'] == u'error':
            raise RuntimeError(m['data'])
        return int(m['cell_id']), str(m['cell_status'])
 def test_step1(self):
     """enter config options about app"""
     url = misc.URL + '/addapp/step2'
     appname = APP
     description = 'this is a test case'
     category = 'bioinformatics'
     command = '../../../../apps/' + appname + os.sep + appname
     user = '******'
     input_format = 'namelist'
     values = {
         'appname': appname,
         'description': description,
         'input_format': input_format,
         'category': category,
         'command': command,
         'user': user
     }
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("Upload zip file", html)
 def test_step4(self):
     url = misc.URL + '/addapp/step5'
     bool_rep = 'T'
     appname = APP
     input_format = 'ini'
     html_tags = ['text', 'hidden', 'select', 'checkbox']
     descriptions = [
         'this is a textbox', 'this is a hidden input',
         'this is a select tag', 'this is a checkbox'
     ]
     keys = ['par1', 'par2', 'par3']
     values = {
         'bool_rep': bool_rep,
         'input_format': input_format,
         'appname': appname,
         'descriptions': descriptions,
         'html_tags': html_tags,
         'keys': keys
     }
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("Template file successfully written", html)
Exemplo n.º 12
0
def post(url, payload):
    print('-------------------> req post')
    print('-------------------> %s' % api['base'])
    url = api['base'] + url
    print('-------------------> %s' % url)
    return misc.post(url, payload, True)
Exemplo n.º 13
0
 def test_check_user_false(self):
     url = misc.URL + '/check_user'
     values = {'user': '******'}
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("false", html)
Exemplo n.º 14
0
 def test_check_user_true(self):
     url = misc.URL + '/check_user'
     values = {'user': '******'}
     (code, html) = misc.post(url, values)
     self.assertEqual(code, httplib.OK)
     self.assertIn("true", html)
Exemplo n.º 15
0
def send_status_mesg(id, frontend_uri, status):
    uri = status_update_uri(frontend_uri)
    data={'id':id, 'status':status}
    log.debug("Sending status update to %s with data=%s"%(uri, data))
    misc.post(uri, data=data)