2929
3030class TestHbaseDescriptor (unittest .TestCase ):
3131 @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 ):
3533
3634 my_text = '[{"table":"a_table", "col_family":"a_cf", "hive_schema":[]}]'
3735 mocked_open_function = mock_open (read_data = my_text )
@@ -49,10 +47,11 @@ def test_normal_use(self, pyhs_mock, hbase_mock):
4947 hbase_mock .return_value .table .return_value .create .assert_called_once_with ('a_cf' )
5048
5149 @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"]}]'
5553 mocked_open_function = mock_open (read_data = my_text )
54+ subprocess_mock .return_value = 'something'
5655
5756 with patch ("__builtin__.open" , mocked_open_function ):
5857 environment = {
@@ -65,5 +64,4 @@ def test_with_impala_schema(self, pyhs_mock, hbase_mock):
6564 hbase_mock .assert_called_once_with (host = '1.2.3.4' , port = 2231 )
6665 hbase_mock .return_value .table .assert_called_once_with ('a_table' )
6766 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