Skip to content

Commit

Permalink
Merge pull request #74 from realifetech/feature/CTD-1855-tdc---be-map…
Browse files Browse the repository at this point in the history
…-ticket-data-to-rlt

CTD-1855 fix UserAlias error
  • Loading branch information
tomrutherford-livestyled committed Apr 25, 2022
2 parents fbdae69 + 5583c69 commit e89f1e5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
10 changes: 4 additions & 6 deletions livestyled/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,25 @@ def placeholder(
class UserAlias:
def __init__(
self,
id: int,
user_alias_type,
user,
value,
updated_at: datetime,
created_at: datetime
updated_at: datetime or None = None,
created_at: datetime or None = None
):
self.id = id
self.user_alias_type = User.placeholder(int(user_alias_type))
self.user = User.placeholder(int(user))
self.value = value
self.created_at = created_at
self.updated_at = updated_at

@classmethod
def create_new(
cls,
user,
user_alias_type,
value
):
user_alias = UserAlias(
user=user,
user_alias_type=user_alias_type,
value=value,
updated_at=None,
Expand Down
13 changes: 11 additions & 2 deletions livestyled/schemas/tests/fixtures/example_user.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,14 @@
"updatedAt": "2020-02-19T18:28:27+00:00"
}
],
"cohorts": []
}
"cohorts": [],
"userAliases": [
{
"@id": "/user_management/user_aliases/510",
"@type": "UserAlias",
"id": 510,
"userAliasType": "/user_management/user_alias_types/4",
"value": "test1234"
}
]
}
10 changes: 9 additions & 1 deletion livestyled/schemas/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ def test_deserialize_user():
'wifi_connected': True
}
],
'user_aliases': []
'user_aliases': [
{
'id': 510,
'user_alias_type': 4,
'value': 'test1234',
'created_at': None,
'updated_at': None
}
]
}


Expand Down
11 changes: 10 additions & 1 deletion livestyled/tests/fixtures/mock_responses/ls_api/user_1234.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@
"/v4/cohorts/1",
"/v4/cohorts/2",
"/v4/cohorts/8"
],
"userAliases": [
{
"@id": "/user_management/user_aliases/510",
"@type": "UserAlias",
"id": 510,
"userAliasType": "/user_management/user_alias_types/4",
"value": "test1234"
}
]
}
}

0 comments on commit e89f1e5

Please sign in to comment.