def test_get_partitions(self, mock_get_conn): response = [{ 'Partitions': [{ 'Values': ['2015-01-01'] }] }] mock_paginator = mock.Mock() mock_paginator.paginate.return_value = response mock_conn = mock.Mock() mock_conn.get_paginator.return_value = mock_paginator mock_get_conn.return_value = mock_conn hook = AwsGlueCatalogHook(region_name="us-east-1") result = hook.get_partitions('db', 'tbl', expression='foo=bar', page_size=2, max_items=3) self.assertEqual(result, {('2015-01-01',)}) mock_conn.get_paginator.assert_called_once_with('get_partitions') mock_paginator.paginate.assert_called_once_with(DatabaseName='db', TableName='tbl', Expression='foo=bar', PaginationConfig={ 'PageSize': 2, 'MaxItems': 3})
def test_get_partitions_empty(self, mock_get_conn): response = set() mock_get_conn.get_paginator.paginate.return_value = response hook = AwsGlueCatalogHook(region_name="us-east-1") self.assertEqual(hook.get_partitions('db', 'tbl'), set())