Skip to content

Commit

Permalink
Added test to run a hive task and mock out the hive command
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Bernhardsson committed Feb 6, 2015
1 parent f05c386 commit e99f7f1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/contrib/hive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,21 @@ def test_import_old(self):
self.assertEquals(luigi.hive, luigi.contrib.hive)


class MyHiveTask(hive.HiveQueryTask):
param = luigi.Parameter()

def query(self):
return 'banana banana %s' % self.param


class TestHiveTask(unittest.TestCase):

@mock.patch('luigi.hadoop.run_and_track_hadoop_job')
def test_run(self, run_and_track_hadoop_job):
success = luigi.run(['MyHiveTask', '--param', 'foo', '--local-scheduler', '--no-lock'])
self.assertTrue(success)
self.assertEquals('hive', run_and_track_hadoop_job.call_args[0][0][0])


if __name__ == '__main__':
unittest.main()

0 comments on commit e99f7f1

Please sign in to comment.