Esempio n. 1
0
    def test_status(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
            self.assertEqual(query.status, STATE_SUCCESS)

            query = MyriaQuery(RUNNING_QUERY_ID, connection=self.connection)
            self.assertEqual(query.status, STATE_RUNNING)
Esempio n. 2
0
    def test_connection(self):
        with HTTMock(local_mock):
            query = MyriaQuery(QUERY_ID, connection=self.connection)
            self.assertEqual(query.connection, self.connection)

            query = MyriaQuery(QUERY_ID)
            self.assertEqual(query.connection, MyriaRelation.DefaultConnection)
Esempio n. 3
0
    def test_dict(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
            self.assertEqual(query.to_dict(), TUPLES)

            query = MyriaQuery(RUNNING_QUERY_ID,
                               connection=self.connection,
                               timeout=1)
            self.assertRaises(requests.Timeout, query.to_dict)
Esempio n. 4
0
    def test_dict(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
            self.assertEqual(query.to_dict(), TUPLES)

            query = MyriaQuery(RUNNING_QUERY_ID,
                               connection=self.connection,
                               timeout=1)
            self.assertRaises(requests.Timeout,
                              query.to_dict)
Esempio n. 5
0
    def test_dict(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
            self.assertEqual(query.to_dict(), TUPLES)

            for i in xrange(1, len(TUPLES) + 1):
                self.assertEqual(query.to_dict(limit=i), TUPLES[:i])

            query = MyriaQuery(RUNNING_QUERY_ID,
                               connection=self.connection,
                               timeout=1)
            self.assertRaises(requests.Timeout,
                              query.to_dict)
Esempio n. 6
0
 def test_timeout(self):
     timeout = 999
     with HTTMock(local_mock):
         query = MyriaQuery(QUERY_ID,
                            connection=self.connection,
                            timeout=timeout)
         self.assertEqual(query.timeout, timeout)
Esempio n. 7
0
    def test_parallel_import(self):
        with HTTMock(local_mock):
            schema = MyriaSchema({'columnNames': ['column'],
                                  'columnTypes': ['INT_TYPE']})
            relation = MyriaRelation(FULL_NAME,
                                     schema=schema,
                                     connection=self.connection)
            work = [('http://input-uri-0', 0), ('http://input-uri-1', 1)]

            query = MyriaQuery.parallel_import(relation, work)
            self.assertEquals(query.status, 'Unittest-Success')
Esempio n. 8
0
    def test_wait_for_completion(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID,
                               connection=self.connection,
                               wait_for_completion=True,
                               timeout=1)
            self.assertEqual(query.status, STATE_SUCCESS)

            self.assertRaises(requests.Timeout,
                              MyriaQuery,
                              RUNNING_QUERY_ID,
                              connection=self.connection,
                              wait_for_completion=True,
                              timeout=1)

            query = MyriaQuery(RUNNING_QUERY_ID,
                               connection=self.connection,
                               wait_for_completion=False,
                               timeout=1)
            self.assertRaises(requests.Timeout, query.wait_for_completion)
Esempio n. 9
0
    def execute(self, relation=None):
        """
        Execute a query
        :param relation: The name of a relation in which the result is stored
        :return: A MyriaQuery instance that represents the executing query
        """
        from myria.query import MyriaQuery

        if not self.result:
            json = self._store(relation or _unique_name(self.query)).to_json()
            self.result = MyriaQuery.submit_plan(json, self.connection)
        return self.result
Esempio n. 10
0
    def execute(self, relation=None):
        """
        Execute a query
        :param relation: The name of a relation in which the result is stored
        :return: A MyriaQuery instance that represents the executing query
        """
        from myria.query import MyriaQuery

        if not self.result:
            json = self._store(relation or _unique_name(self.query)).to_json()
            self.result = MyriaQuery.submit_plan(json, self.connection)
        return self.result
Esempio n. 11
0
    def test_parallel_import(self):
        with HTTMock(local_mock):
            schema = MyriaSchema({
                'columnNames': ['column'],
                'columnTypes': ['INT_TYPE']
            })
            relation = MyriaRelation(FULL_NAME,
                                     schema=schema,
                                     connection=self.connection)
            work = [('http://input-uri-0', 0), ('http://input-uri-1', 1)]

            query = MyriaQuery.parallel_import(relation, work)
            self.assertEquals(query.status, 'Unittest-Success')
Esempio n. 12
0
    def test_dict(self):
        with HTTMock(local_mock):
            query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
            self.assertEqual(query.to_dict(), TUPLES)

            for i in xrange(1, len(TUPLES) + 1):
                self.assertEqual(query.to_dict(limit=i), TUPLES[:i])

            query = MyriaQuery(RUNNING_QUERY_ID,
                               connection=self.connection,
                               timeout=1)
            self.assertRaises(requests.Timeout, query.to_dict)
Esempio n. 13
0
 def test_name(self):
     with HTTMock(local_mock):
         query = MyriaQuery(COMPLETED_QUERY_ID, connection=self.connection)
         self.assertEqual(query.name, FULL_NAME)
         self.assertEqual(query.qualified_name, QUALIFIED_NAME)
         self.assertEqual(query.components, NAME_COMPONENTS)
Esempio n. 14
0
 def test_submit_program(self):
     with HTTMock(local_mock):
         program = 'COMPLETE_IMMEDIATELY = empty(i:int);\n' \
                   'store(COMPLETE_IMMEDIATELY, COMPLETE_IMMEDIATELY);'
         query = MyriaQuery.submit(program, connection=self.connection)
         self.assertEquals(query.status, STATE_SUCCESS)
Esempio n. 15
0
 def test_submit_plan(self):
     with HTTMock(local_mock):
         plan = 'This is a Myria JSON plan'
         query = MyriaQuery.submit_plan(plan, connection=self.connection)
         self.assertEquals(query.status, 'Unittest-Success')
Esempio n. 16
0
 def test_submit_program(self):
     with HTTMock(local_mock):
         program = 'COMPLETE_IMMEDIATELY = empty(i:int);\n' \
                   'store(COMPLETE_IMMEDIATELY, COMPLETE_IMMEDIATELY);'
         query = MyriaQuery.submit(program, connection=self.connection)
         self.assertEquals(query.status, STATE_SUCCESS)
Esempio n. 17
0
 def test_submit_plan(self):
     with HTTMock(local_mock):
         plan = 'This is a Myria JSON plan'
         query = MyriaQuery.submit_plan(plan, connection=self.connection)
         self.assertEquals(query.status, 'Unittest-Success')
Esempio n. 18
0
 def sink(self):
     """ Execute the query but ignore its results """
     from myria.query import MyriaQuery
     return MyriaQuery.submit_plan(self._sink().to_json(), self.connection)
Esempio n. 19
0
 def sink(self):
     """ Execute the query but ignore its results """
     from myria.query import MyriaQuery
     return MyriaQuery.submit_plan(self._sink().to_json(), self.connection)
Esempio n. 20
0
 def test_id(self):
     with HTTMock(local_mock):
         query = MyriaQuery(QUERY_ID, connection=self.connection)
         self.assertEqual(query.query_id, QUERY_ID)