Skip to content

Commit

Permalink
hive test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Bernhardsson committed Feb 6, 2015
1 parent 4819f6a commit 0616841
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/contrib/hive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@

from unittest import TestCase

from luigi import hive
import luigi
from luigi.contrib import hive
import mock


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

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


def test_error_cmd(self):
self.assertRaises(hive.HiveCommandError, hive.run_hive_cmd, "this is a bogus command and should cause an error;")
class TestHiveTask(TestCase):

def test_ok_cmd(self):
"Test that SHOW TABLES doesn't throw an error"
hive.run_hive_cmd("SHOW TABLES;")
@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])

0 comments on commit 0616841

Please sign in to comment.