def test_review_status(self): """Test not_empty_revisions works correcly with review status change.""" instance = factories.ProgramFactory() def mark_as_reviewed(instance): """Helper function to mark `instance` as reviewed.""" response = self.api.post( all_models.Review, { "review": { "reviewable": { "type": instance.type, "id": instance.id, }, "context": None, "notification_type": "email", "status": all_models.Review.STATES.REVIEWED, "access_control_list": review.build_reviewer_acl(), }, }, ) self.assertStatus(response, 201) mark_as_reviewed(instance) instance = self._refresh_instance(instance.type, instance.id) revisions_count = self._count_revisions(instance) not_empty_revisions = self._query_not_empty_revisions(instance) self.assertEqual(revisions_count, 2) self.assertEqual(len(not_empty_revisions), 2)
def test_unmap_people(self, user_role): """Test that global reader/creator can't unmap people from program""" user = self.users[user_role] with factories.single_commit(): program = factories.ProgramFactory() mapped_person = factories.ObjectPersonFactory( personable=program, person=user, context=program.context) self.api.set_user(user) db.session.add(mapped_person) response = self.api.delete(mapped_person) self.assertEqual(response.status_code, 403)
def test_not_empty_revisions(self): """Test `not_empty_revisions` returns revisions with changes.""" self._turn_on_bg_indexing() instance = factories.ProgramFactory() def edit_without_changes(instance): """Helper function to perform instance edit without actual changes.""" response = self.api.put(instance, {}) self.assert200(response) edit_without_changes(instance) instance = self._refresh_instance(instance.type, instance.id) revisions_count = self._count_revisions(instance) not_empty_revisions = self._query_not_empty_revisions(instance) self.assertEqual(revisions_count, 2) self.assertEqual(len(not_empty_revisions), 1) self._turn_off_bg_indexing()