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 7f4d78f commit 4c13e6a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/contrib/hive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,23 @@ def test_ok_cmd(self):

def test_import_old(self):
import luigi.hive
self.assertEquals(luigi.hive, luigi.contrib.hive)
self.assertEquals(luigi.hive.HiveQueryTask, luigi.contrib.hive.HiveQueryTask)


class MyHiveTask(luigi.contrib.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__':
Expand Down

0 comments on commit 4c13e6a

Please sign in to comment.