29
29
30
30
class TestHbaseDescriptor (unittest .TestCase ):
31
31
@patch ('starbase.Connection' )
32
- @patch ('pyhs2.connect' )
33
- def test_normal_use (self , pyhs_mock , hbase_mock ):
34
- pyhs_mock .return_value = Mock ()
32
+ def test_normal_use (self , hbase_mock ):
35
33
36
34
my_text = '[{"table":"a_table", "col_family":"a_cf", "hive_schema":[]}]'
37
35
mocked_open_function = mock_open (read_data = my_text )
@@ -49,10 +47,11 @@ def test_normal_use(self, pyhs_mock, hbase_mock):
49
47
hbase_mock .return_value .table .return_value .create .assert_called_once_with ('a_cf' )
50
48
51
49
@patch ('starbase.Connection' )
52
- @patch ('pyhs2.connect ' )
53
- def test_with_impala_schema (self , pyhs_mock , hbase_mock ):
54
- my_text = '[{"table":"a_table", "col_family":"a_cf", "hive_schema":["some ddl","more ddl" ]}]'
50
+ @patch ('subprocess.check_output ' )
51
+ def test_with_impala_schema (self , subprocess_mock , hbase_mock ):
52
+ my_text = '[{"table":"a_table", "col_family":"a_cf", "hive_schema":["some ddl"]}]'
55
53
mocked_open_function = mock_open (read_data = my_text )
54
+ subprocess_mock .return_value = 'something'
56
55
57
56
with patch ("__builtin__.open" , mocked_open_function ):
58
57
environment = {
@@ -65,5 +64,4 @@ def test_with_impala_schema(self, pyhs_mock, hbase_mock):
65
64
hbase_mock .assert_called_once_with (host = '1.2.3.4' , port = 2231 )
66
65
hbase_mock .return_value .table .assert_called_once_with ('a_table' )
67
66
hbase_mock .return_value .table .return_value .create .assert_called_once_with ('a_cf' )
68
- pyhs_mock .return_value .cursor .return_value .execute .assert_any_call ('some ddl' )
69
- pyhs_mock .return_value .cursor .return_value .execute .assert_any_call ('more ddl' )
67
+ subprocess_mock .assert_called_once_with (["beeline" , "-u" , "jdbc:hive2://5.6.7.8:9876/;transportMode=http;httpPath=cliservice" , "-e" , "some ddl" ])
0 commit comments