def test_user_can_create_rainbarrel_photo(self): self._add_builtin_permission(self.role_yes, MapFeaturePhoto, 'add_rainbarrelphoto') rainbarrel = self._create_rainbarrel_return_map_feature() user_yes = make_user(instance=self.instance, make_role=lambda inst: self.role_yes) photo = MapFeaturePhoto(instance=self.instance, map_feature=rainbarrel) photo.set_image(self.load_resource('tree1.gif')) self.assertTrue(photo.user_can_create(user_yes))
def test_user_cannot_create_rainbarrel_photo(self): self._add_builtin_permission(self.role_no, RainBarrel, 'add_rainbarrel') self._add_builtin_permission(self.role_no, Bioswale, 'add_bioswale') self._add_builtin_permission(self.role_no, MapFeaturePhoto, 'add_bioswalephoto') rainbarrel = self._create_rainbarrel_return_map_feature() user_no = make_user(instance=self.instance, make_role=lambda inst: self.role_no) photo = MapFeaturePhoto(instance=self.instance, map_feature=rainbarrel) photo.set_image(self.load_resource('tree1.gif')) self.assertFalse(photo.user_can_create(user_no))