Skip to content

Commit

Permalink
[DAE-63] Remove method returning for create_database_if_not_exists (#39)
Browse files Browse the repository at this point in the history
* Remove method returning

* Update docs
  • Loading branch information
Lucas Mendes Mota da Fonseca authored Jan 27, 2021
1 parent 29ca477 commit 41eca7b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/source/getstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ Beyond the default methods, this library also implements the methods below in
the [`HiveMetastoreClient`](https://github.com/quintoandar/hive-metastore-client/blob/main/hive_metastore_client/hive_metastore_client.py) class:

- [`add_columns_to_table`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_columns_to_table)
- [`add_partitions_to_table`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_columns_to_table)
- [`add_partitions_to_table`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.add_partitions_to_table)
- [`create_database_if_not_exists`](https://hive-metastore-client.readthedocs.io/en/latest/hive_metastore_client.html#hive_metastore_client.hive_metastore_client.HiveMetastoreClient.create_database_if_not_exists)
5 changes: 2 additions & 3 deletions hive_metastore_client/hive_metastore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def add_partitions_to_table(

self.add_partitions(partition_list_with_correct_location)

def create_database_if_not_exists(self, database: Database) -> bool:
def create_database_if_not_exists(self, database: Database) -> None:
"""
Creates the table in Hive Metastore if it does not exist.
Expand All @@ -145,9 +145,8 @@ def create_database_if_not_exists(self, database: Database) -> bool:
"""
try:
self.create_database(database)
return True
except AlreadyExistsException:
return False
pass

@staticmethod
def _format_partitions_location(
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/hive_metastore_client/test_hive_metastore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,9 @@ def test_create_database_if_not_exists_with_nonexistent_database(
mocked_database_obj = Mock()

# act
return_value = hive_metastore_client.create_database_if_not_exists(
mocked_database_obj
)
hive_metastore_client.create_database_if_not_exists(mocked_database_obj)

# assert
assert return_value
mocked_create_database.assert_called_once_with(mocked_database_obj)

@mock.patch.object(HiveMetastoreClient, "create_database")
Expand All @@ -236,10 +233,7 @@ def test_create_database_if_not_exists_with_existent_database(
mocked_create_database.side_effect = AlreadyExistsException()

# act
return_value = hive_metastore_client.create_database_if_not_exists(
mocked_database_obj
)
hive_metastore_client.create_database_if_not_exists(mocked_database_obj)

# assert
assert not return_value
mocked_create_database.assert_called_once_with(mocked_database_obj)

0 comments on commit 41eca7b

Please sign in to comment.