Skip to content

Commit

Permalink
Updates the test cases, based on owner changes
Browse files Browse the repository at this point in the history
Signed-off-by: verdan <[email protected]>
  • Loading branch information
verdan committed Aug 17, 2020
1 parent b8a3fc2 commit 6e28285
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion metadata_service/proxy/atlas_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def add_owner(self, *, table_uri: str, owner: str) -> None:
:return: None, as it simply adds the owner.
"""
# noinspection PyArgumentList
if not self.user_detail_method(owner) or owner:
if not (self.user_detail_method(owner) or owner):
raise NotFoundException(f'User "{owner}" does not exist.')

user_dict = {
Expand Down
18 changes: 13 additions & 5 deletions tests/unit/proxy/test_atlas_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def _get_table(self, custom_stats_format: bool = False) -> None:
test_exp_col = self.test_exp_col_stats_formatted
else:
test_exp_col = self.test_exp_col_stats_raw

ent_attrs = cast(dict, self.entity1['attributes'])
self._mock_get_table_entity()
self._create_mocked_report_entities_collection()
self.proxy._get_owners = MagicMock(return_value=[User(email=ent_attrs['owner'])])
self.proxy._driver.entity_bulk = MagicMock(return_value=self.report_entity_collection)
response = self.proxy.get_table(table_uri=self.table_uri)

classif_name = self.classification_entity['classifications'][0]['typeName']
ent_attrs = cast(dict, self.entity1['attributes'])

col_attrs = cast(dict, self.test_column['attributes'])
exp_col_stats = list()
Expand Down Expand Up @@ -256,10 +256,18 @@ def test_delete_tag(self) -> None:

def test_add_owner(self) -> None:
owner = "OWNER"
entity = self._mock_get_table_entity()
with patch.object(entity, 'update') as mock_execute:
user_guid = 123
self._mock_get_table_entity()
self.proxy._driver.entity_post = MagicMock()
self.proxy._driver.entity_post.create = MagicMock(return_value={"guidAssignments": {user_guid: user_guid}})

with patch.object(self.proxy._driver.relationship, 'create') as mock_execute:
self.proxy.add_owner(table_uri=self.table_uri, owner=owner)
mock_execute.assert_called_with()
mock_execute.assert_called_with(
data={'typeName': 'DataSet_Users_Owner',
'end1': {'guid': self.entity1['guid'], 'typeName': 'Table'},
'end2': {'guid': user_guid, 'typeName': 'User'}}
)

def test_get_column(self) -> None:
self._mock_get_table_entity()
Expand Down

0 comments on commit 6e28285

Please sign in to comment.