Skip to content

Commit

Permalink
Fix user unit test (#136)
Browse files Browse the repository at this point in the history
* Pin common deps to unblock

* fix

* Fix unit test
  • Loading branch information
feng-tao authored May 15, 2020
1 parent 7f3a543 commit 1d470ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metadata_service/proxy/neo4j_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def _build_user_from_record(record: dict, manager_name: str = '') -> UserEntity:
slack_id=record.get('slack_id'),
employee_type=record.get('employee_type'),
role_name=record.get('role_name'),
manager_fullname=manager_name)
manager_fullname=record.get('manager_fullname', manager_name))

@staticmethod
def _get_user_resource_relationship_clause(relation_type: UserResourceRel, id: str = None,
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/proxy/test_neo4j_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,24 @@ def test_get_users(self) -> None:
'first_name': 'test_first_name',
'team_name': 'test_team',
'email': 'test_email',
'manager_fullname': ''
'manager_fullname': 'test_manager',
}
mock_execute.return_value.single.return_value = {'users': [test_user]}
neo4j_proxy = Neo4jProxy(host='DOES_NOT_MATTER', port=0000)
users = neo4j_proxy.get_users()
self.assertEquals(users, UserSchema(many=True).load([test_user]).data)
actual_data = UserSchema(many=True).load([test_user]).data
for attr in ['employee_type',
'full_name',
'is_active',
'github_username',
'slack_id',
'last_name',
'first_name',
'team_name',
'email',
'manager_fullname']:
self.assertEquals(getattr(users[0], attr),
getattr(actual_data[0], attr))

def test_get_table_by_user_relation(self) -> None:
with patch.object(GraphDatabase, 'driver'), patch.object(Neo4jProxy, '_execute_cypher_query') as mock_execute:
Expand Down

0 comments on commit 1d470ae

Please sign in to comment.