def setUp(self): self.app = make_test_app() Entity.all().delete() # Consistently include an extra private project with Entity # that should not show in any test results project, permission = _project_and_permission(private=True) entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD) db.session.add(entity)
def test_all_entities__not_private_published(self): project, permission = _project_and_permission(private=False) entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD) db.session.add(entity) db.session.commit() with self.app.test_request_context(): flask.session['id'] = 1 self.app.preprocess_request() q = db.session.query(Entity) self.assertEqual(filters.for_entities(q, Entity).count(), 1)
def test_all_entities__private_reader_draft(self): project, permission = _project_and_permission(reader=True, private=True) entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD - 1) db.session.add(entity) db.session.commit() with self.app.test_request_context(): flask.session['id'] = 1 self.app.preprocess_request() q = db.session.query(Entity) self.assertEqual(filters.for_entities(q, Entity).count(), 0)
def test_all_entities__private_reader_draft(self): project, permission = _project_and_permission( reader=True, private=True) entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD-1) db.session.add(entity) db.session.commit() with self.app.test_request_context(): flask.session['id'] = 1 self.app.preprocess_request() q = db.session.query(Entity) self.assertEqual(filters.for_entities(q, Entity).count(), 0)