def test_only_directors_can_see_delete_link(self): trips_year = trips_year_recipe.make() raid = raid_recipe.make(trips_year=trips_year) resp = self.app.get(raid.detail_url(), user=self.mock_user()) self.assertNotContains(resp, 'delete') resp = self.app.get(raid.detail_url(), user=self.mock_director()) self.assertContains(resp, 'delete')
def test_only_directors_can_delete_raids(self): trips_year = trips_year_recipe.make() raid = raid_recipe.make(trips_year=trips_year) url = raid.delete_url() self.app.get(url, user=self.mock_user(), status=403) # No good resp = self.app.get(url, user=self.mock_director()) # OK resp.form.submit() with self.assertRaises(Raid.DoesNotExist): Raid.objects.get()