def test_save_fails_if_integrity_error(self): """Test save raises a DBIntegrityError if the instance to be saved lacks a required value""" helpingmaterial = HelpingMaterialFactory.build(project_id=None) assert_raises(DBIntegrityError, self.helping_repo.save, helpingmaterial)
def test_anonymous_user_create_given_helpingmaterial(self): """Test anonymous users cannot create helping materials for a project""" project = ProjectFactory.create() helping = HelpingMaterialFactory.build(project_id=project.id) assert_raises(Unauthorized, ensure_authorized_to, 'create', helping)
def test_anonymous_user_create_given_helpingmaterial(self): """Test anonymous users cannot create helping materials for a project""" project = ProjectFactory.create() helping = HelpingMaterialFactory.build(project_id=project.id) assert_raises(Unauthorized, ensure_authorized_to, 'create', helping)
def test_save_fails_if_integrity_error(self): """Test save raises a DBIntegrityError if the instance to be saved lacks a required value""" helpingmaterial = HelpingMaterialFactory.build(project_id=None) assert_raises(DBIntegrityError, self.helping_repo.save, helpingmaterial)
def test_owner_create_given_helpingmaterial(self): """Test authenticated user can create a given helpingmaterial if it's project owner""" owner = UserFactory.create(id=2) project = ProjectFactory.create(owner=owner) helpingmaterial = HelpingMaterialFactory.build(project_id=project.id) assert self.mock_authenticated.id == project.owner_id assert_not_raises(Exception, ensure_authorized_to, 'create', helpingmaterial)
def test_non_owner_authenticated_user_create_given_helpingmaterial(self): """Test authenticated user cannot create a given helpingmaterial if is not the project owner""" project = ProjectFactory.create() helpingmaterial = HelpingMaterialFactory.build(project_id=project.id) assert self.mock_authenticated.id != project.owner_id assert_raises(Forbidden, ensure_authorized_to, 'create', helpingmaterial)
def test_owner_create_given_helpingmaterial(self): """Test authenticated user can create a given helpingmaterial if it's project owner""" owner = UserFactory.create(id=2) project = ProjectFactory.create(owner=owner) helpingmaterial = HelpingMaterialFactory.build(project_id=project.id) assert self.mock_authenticated.id == project.owner_id assert_not_raises(Exception, ensure_authorized_to, 'create', helpingmaterial)
def test_non_owner_authenticated_user_create_given_helpingmaterial(self): """Test authenticated user cannot create a given helpingmaterial if is not the project owner""" project = ProjectFactory.create() helpingmaterial = HelpingMaterialFactory.build(project_id=project.id) assert self.mock_authenticated.id != project.owner_id assert_raises(Forbidden, ensure_authorized_to, 'create', helpingmaterial)
def test_save(self): """Test save persist the helpingmaterial""" helpingmaterial = HelpingMaterialFactory.build() project = ProjectFactory.create() helpingmaterial.project_id = project.id assert self.helping_repo.get(helpingmaterial.id) is None self.helping_repo.save(helpingmaterial) assert self.helping_repo.get(helpingmaterial.id) == helpingmaterial, "Helping material not saved"
def test_save(self): """Test save persist the helpingmaterial""" helpingmaterial = HelpingMaterialFactory.build() project = ProjectFactory.create() helpingmaterial.project_id = project.id assert self.helping_repo.get(helpingmaterial.id) is None self.helping_repo.save(helpingmaterial) assert self.helping_repo.get( helpingmaterial.id ) == helpingmaterial, "Helping material not saved"