def test_owner_delete(self): self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"]) pm_delete( self.mockRequest(user=self.user1, matchdict={"id": self.pm1.id})) self.assertNotIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"])
def test_other_delete(self): DBSession.add( self.user2 ) # somehow this ends up not in the session after setUp() o_O self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"]) self.assertRaises( HTTPForbidden, pm_delete, self.mockRequest(user=self.user2, matchdict={"id": self.pm1.id})) self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"])
def test_valid_send(self): DBSession.add(self.user0) request = self.mockRequest(user=self.user0, POST={"to": u"test-user1", "subject": u"message~", "message": u"here is some text :3"}) info = pm_create(request) info = pm_list(testing.DummyRequest(user=self.user1)) self.assertIn("message~", [pm.subject for pm in info["pms"]])
def test_valid_send(self): DBSession.add(self.user0) request = self.mockRequest(user=self.user0, POST={ "to": u"test-user1", "subject": u"message~", "message": u"here is some text :3" }) info = pm_create(request) info = pm_list(testing.DummyRequest(user=self.user1)) self.assertIn("message~", [pm.subject for pm in info["pms"]])
def test_basic(self): request = testing.DummyRequest(user=self.user1) info = pm_list(request) self.assertIn(self.pm1, info["pms"]) self.assertIn(self.pm3, info["pms"])
def test_other_delete(self): DBSession.add(self.user2) # somehow this ends up not in the session after setUp() o_O self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"]) self.assertRaises(HTTPForbidden, pm_delete, self.mockRequest(user=self.user2, matchdict={"id": self.pm1.id})) self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"])
def test_admin_delete(self): self.assertIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"]) pm_delete(self.mockRequest(user=self.user0, matchdict={"id": self.pm1.id})) self.assertNotIn(self.pm1, pm_list(testing.DummyRequest(user=self.user1))["pms"])