def test_cohorts_edit_with_no_users(pyramid_request): cohort = models.FeatureCohort(name='FractalCohort') pyramid_request.db.add(cohort) pyramid_request.db.flush() pyramid_request.matchdict['id'] = cohort.id result = cohorts_edit({}, pyramid_request) assert result['cohort'].id == cohort.id assert len(result['cohort'].members) == 0
def test_cohorts_edit_with_users(factories, pyramid_request): cohort = models.FeatureCohort(name='FractalCohort') user1 = factories.User(username='******') user2 = factories.User(username='******', authority='foo.org') cohort.members.append(user1) cohort.members.append(user2) pyramid_request.db.add(cohort) pyramid_request.db.flush() pyramid_request.matchdict['id'] = cohort.id result = cohorts_edit({}, pyramid_request) assert result['cohort'].id == cohort.id assert len(result['cohort'].members) == 2