def test_commish_search_invalid(): # searcher u1 = db_utils.create_user(username="******") # user not open for commissions, but with submissions and commish classes defined create_commish_searchable_user("u2", commish_status='c') # user open for commission but without any commish classes u3 = create_commish_searchable_user("u3") classid = commishinfo.select_list(u3)["class"][0]["classid"] commishinfo.remove_class(u3, classid) # user meets all requirements, but is suspended u4 = create_commish_searchable_user("u4") db_utils.create_suspenduser(u4, "", arrow.now() + datetime.timedelta(days=7)) # user meets all requirements, but is banned u5 = create_commish_searchable_user("u5") db_utils.create_banuser(u5, "") # user meets all requirements, but is ignored by searching user u6 = create_commish_searchable_user("u6") db_utils.create_ignoreuser(u1, u6) results = commishinfo.select_commissionable(userid=u1, limit=10, offset=0, q="", commishclass="", min_price=None, max_price=None, currency='') assert not results
def test_commish_search_invalid(): # searcher u1 = db_utils.create_user(username="******") # user not open for commissions, but with submissions and commish classes defined create_commish_searchable_user("u2", commish_status='c') # user open for commission but without any commish classes u3 = create_commish_searchable_user("u3") classid = commishinfo.select_list(u3)["class"][0]["classid"] commishinfo.remove_class(u3, classid) # user meets all requirements, but is suspended u4 = create_commish_searchable_user("u4") db_utils.create_suspenduser(u4, "", d.get_time() + 604800) # user meets all requirements, but is banned u5 = create_commish_searchable_user("u5") db_utils.create_banuser(u5, "") # user meets all requirements, but is ignored by searching user u6 = create_commish_searchable_user("u6") db_utils.create_ignoreuser(u1, u6) results = commishinfo.select_commissionable(userid=u1, limit=10, offset=0, q="", commishclass="", min_price=None, max_price=None, currency='') assert not results
def test_insert_ignores(self): user1 = db_utils.create_user() user2 = db_utils.create_user() # user1 ignores user2 db_utils.create_ignoreuser(user1, user2) # attempts to follow in either direction throw a WeasylError self.assertRaises(WeasylError, followuser.insert, user1, user2) self.assertRaises(WeasylError, followuser.insert, user2, user1) self.assertFalse(profile.select_relation(user1, user2)["follow"]) self.assertFalse(profile.select_relation(user2, user1)["follower"])
def test_insert_ignores(self): user1 = db_utils.create_user() user2 = db_utils.create_user() # user1 ignores user2 db_utils.create_ignoreuser(user1, user2) # attempts to follow in either direction throw a WeasylError self.assertRaises(WeasylError, followuser.insert, user1, user2) self.assertRaises(WeasylError, followuser.insert, user2, user1) self.assertFalse(profile.select_relation(user1, user2)["follow"]) self.assertFalse(profile.select_relation(user2, user1)["follower"])
def test_ignored_user(self): user1 = db_utils.create_user() user2 = db_utils.create_user() db_utils.create_submission(user1, rating=ratings.GENERAL.code) # can view the submission self.assertEqual( 1, len(submission.select_list(user2, ratings.GENERAL.code, 10))) # user2 blocks user1 db_utils.create_ignoreuser(user2, user1) # user2 can no longer view the submission self.assertEqual( 0, len(submission.select_list(user2, ratings.GENERAL.code, 10))) # but a non-logged in user can self.assertEqual( 1, len(submission.select_list(None, ratings.GENERAL.code, 10)))
def test_ignored_user(self): user1 = db_utils.create_user() user2 = db_utils.create_user() db_utils.create_submission(user1, rating=ratings.GENERAL.code) # can view the submission self.assertEqual( 1, len(submission.select_list(user2, ratings.GENERAL.code, 10))) # user2 blocks user1 db_utils.create_ignoreuser(user2, user1) # user2 can no longer view the submission self.assertEqual( 0, len(submission.select_list(user2, ratings.GENERAL.code, 10))) # but a non-logged in user can self.assertEqual( 1, len(submission.select_list(None, ratings.GENERAL.code, 10)))
def setUp(self): # userid of the owner of a submission. self.owner = db_utils.create_user() # userid of a friended follower. self.friend = db_utils.create_user() db_utils.create_follow(self.friend, self.owner) db_utils.create_friendship(self.owner, self.friend) # userid of a non-friended follower. self.nonfriend = db_utils.create_user() db_utils.create_follow(self.nonfriend, self.owner) # userid of an ignored follower. self.ignored = db_utils.create_user() db_utils.create_follow(self.ignored, self.owner) db_utils.create_ignoreuser(self.owner, self.ignored)
def setUp(self): # userid of the owner of a submission. self.owner = db_utils.create_user() # userid of a friended follower. self.friend = db_utils.create_user() db_utils.create_follow(self.friend, self.owner) db_utils.create_friendship(self.owner, self.friend) # userid of a non-friended follower. self.nonfriend = db_utils.create_user() db_utils.create_follow(self.nonfriend, self.owner) # userid of an ignored follower. self.ignored = db_utils.create_user() db_utils.create_follow(self.ignored, self.owner) db_utils.create_ignoreuser(self.owner, self.ignored)
def test_contentOwnerIgnoredYou_WeasylError_if_user_ignored_by_item_owner(): # Set up for this test userid_owner = db_utils.create_user() userid_tag_adder = db_utils.create_user() journalid = db_utils.create_journal(userid_owner) charid = db_utils.create_character(userid_owner) submitid = db_utils.create_submission(userid_owner) db_utils.create_ignoreuser(userid_owner, userid_tag_adder) with pytest.raises(WeasylError) as err: searchtag.associate(userid_tag_adder, tags, submitid=submitid) assert err.value.value == "contentOwnerIgnoredYou" with pytest.raises(WeasylError) as err: searchtag.associate(userid_tag_adder, tags, charid=charid) assert err.value.value == "contentOwnerIgnoredYou" with pytest.raises(WeasylError) as err: searchtag.associate(userid_tag_adder, tags, journalid=journalid) assert err.value.value == "contentOwnerIgnoredYou"