예제 #1
0
    def testTaskClassType(self):
        typed = Task(type='SQL', query='select * from dual')
        self.assertIsInstance(typed, SQLTask)

        unknown_typed = Task(type='UnknownType')
        self.assertIs(type(unknown_typed), Task)
        self.assertRaises(ODPSError, lambda: unknown_typed.serialize())

        untyped = Task()
        self.assertIs(type(untyped), Task)
        self.assertRaises(ODPSError, lambda: untyped.serialize())
예제 #2
0
    def testSQLCostTaskToXML(self):
        query = 'select * from dual'
        task = SQLCostTask(query=query)
        to_xml = task.serialize()
        right_xml = sql_cost_template % {'sql': query}

        self.assertEqual(to_str(to_xml), to_str(right_xml))

        task = Task.parse(None, to_xml)
        self.assertIsInstance(task, SQLCostTask)
예제 #3
0
    def testCupidTaskToXML(self):
        task = CupidTask('task_1', 'plan_text',
                         {'odps.cupid.wait.am.start.time': 600})
        to_xml = task.serialize()
        right_xml = cupid_template

        self.assertEqual(to_str(to_xml), to_str(right_xml))

        task = Task.parse(None, to_xml)
        self.assertIsInstance(task, CupidTask)
예제 #4
0
    def testMergeTaskToXML(self):
        task = MergeTask('task_1', table='table_name')
        task.update_settings({'odps.merge.cross.paths': True})
        to_xml = task.serialize()
        right_xml = merge_template % dict(name='task_1', table='table_name')

        self.assertEqual(to_str(to_xml), to_str(right_xml))

        task = Task.parse(None, to_xml)
        self.assertIsInstance(task, MergeTask)
예제 #5
0
    def testSQLTaskToXML(self):
        query = 'select * from dual'

        task = SQLTask(query=query)
        to_xml = task.serialize()
        right_xml = template % {'sql': query}

        self.assertEqual(to_str(to_xml), to_str(right_xml))

        task = Task.parse(None, to_xml)
        self.assertIsInstance(task, SQLTask)
    def testTaskClassType(self):
        typed = Task(type='SQL', query='select * from dual')
        self.assertIsInstance(typed, SQLTask)

        unknown_typed = Task(type='UnknownType')
        self.assertIs(type(unknown_typed), Task)
        self.assertRaises(ODPSError, lambda: unknown_typed.serialize())

        untyped = Task()
        self.assertIs(type(untyped), Task)
        self.assertRaises(ODPSError, lambda: untyped.serialize())