def testAddSessionToWishlist(self): """ TEST: Add session to the user's wishlist """ self.initDatabase() session = Session.query(Session.name == 'Intro to Poker').get() swsk = session.key.urlsafe() container = SESSION_WISHLIST_POST_REQUEST.combined_message_class( websafeSessionKey=swsk ) self.login() # login as default user r = self.api.addSessionToWishlist(container) profile = ndb.Key(Profile, self.getUserId()).get() assert r.data and session.key in profile.wishList, "Failed to add session to user's wish list"
def testRemoveSessionFromWishlist(self): """ TEST: Remove session from user's wishlist """ self.initDatabase() self.login() # login as default user # verify database fixture prof = ndb.Key(Profile, self.getUserId()).get() session = Session.query(Session.name == 'Intro to Poker').get() assert session and len(prof.wishList) == 0, \ "This shouldn't fail. Maybe someone messed with database fixture" # manually add a session to user's wishlist prof.wishList.append(session.key) prof.put() # build request container = SESSION_WISHLIST_POST_REQUEST.combined_message_class( websafeSessionKey=session.key.urlsafe() ) # remove session from users wishlist r = self.api.removeSessionFromWishlist(container) # re-fetch profile then verify session was removed prof = prof.key.get() assert r.data and session.key not in prof.wishList, "Failed to remove session from user's wish list"