test: created first test case for get_or_create method for UsersResource#384
test: created first test case for get_or_create method for UsersResource#384edward-yee-ny wants to merge 6 commits intoweeklyfrom
Conversation
Removed commented-out code from the test case.
|
Hi Mr Ng, I added a new test function, test_get_or_create_returns_existing_user_when_exists(). Could you help me check this function? Thank you. |
Hi @lohith, I just realized the comment is inaccurate. Please see https://github.com/nyjc-computing/campus/blob/weekly/campus%2Fauth%2Fresources%2Fuser.py for the interface of In general, use the methods available on the resource object, without touching the storage layer. Mediating any changes in data schema is the resource class's responsibility, and the test should not take on that responsibility unless there is good reason. |
saltensity
left a comment
There was a problem hiding this comment.
Resubmit changes for proper usage of the resource
| email = "new_user@gmail.com" | ||
| name = "New_User" | ||
| self.resource.user_storage.insert_one(user_id, email, name) | ||
| timestamp = self.resource.user_storage.get(user_id).created_at |
There was a problem hiding this comment.
Following the previous comment, this line would not be needed
| user_id = schema.UserID("New_User") | ||
| email = "new_user@gmail.com" | ||
| name = "New_User" | ||
| self.resource.user_storage.insert_one(user_id, email, name) |
There was a problem hiding this comment.
You can use the self.resource.new() method to add a new user directly to the resource
(The .new() method also returns the User object for the newly created user, maybe you can store it in a variable and use its created_at?)
No description provided.