def setUp(self): super().setUp() self.to = OwnerInnerDoc(name='to_name', email='*****@*****.**', department='department', team=['team']) self.bo = OwnerInnerDoc(name='bo_name', email='*****@*****.**', department='department', team=['team'])
def parse(users: list) -> dict: result = dict() for user in users: try: result[user['id']] = OwnerInnerDoc( name='{first} {last} ({username})'.format( first=user['first_name'], last=user['last_name'], username=user['username']), email=user['email'], department=user['department'] if user['department'] else '', team=user['team']['name'] if user['team'] else '') except Exception as ex: LOGGER.debug(F'Unable to parse user {ex}') return result
def test_parse_with_users_called(self): users = { 35: OwnerInnerDoc(name='FNAME LNAME (FLBO)', email='*****@*****.**') } result = self.uut.parse(self.hosts, users) self.assert_fields(result) self.assertEqual(result[self.asset_id].business_owner, [{ 'name': 'FNAME LNAME (FLBO)', 'email': '*****@*****.**' }]) self.assertEqual(result[self.asset_id].technical_owner, [{ 'name': 'FNAME LNAME (FLBO)', 'email': '*****@*****.**' }])
def owner(self, item: dict, field_name: str) -> list: owners = [ self.__users[us['id']] for us in item[field_name] if us['id'] in self.__users ] return owners if owners else [OwnerInnerDoc()]