Exemple #1
0
    def test_normal_upload_does_not_call_centralauth(self):
        data = 'Actual validation tested elsewhere'
        centralauth_called = [False]

        def expand_via_ca_mock(cohort_users, session):
            centralauth_called[0] = True
            return []

        ca_service_mock = CentralAuthService()
        ca_service_mock.expand_via_centralauth = expand_via_ca_mock
        with centralauth_service_set(app, ca_service_mock):
            self.app.post('/cohorts/upload',
                          data=dict(name='new_cohort_name',
                                    project='wiki',
                                    csv=(StringIO(data), 'cohort.csv'),
                                    validate_as_user_ids='True',
                                    centralauth=False))
        assert_true(not centralauth_called[0])
    def test_normal_upload_does_not_call_centralauth(self):
        data = 'Actual validation tested elsewhere'
        centralauth_called = [False]

        def expand_via_ca_mock(cohort_users, session):
            centralauth_called[0] = True
            return []

        ca_service_mock = CentralAuthService()
        ca_service_mock.expand_via_centralauth = expand_via_ca_mock
        with centralauth_service_set(app, ca_service_mock):
            self.app.post('/cohorts/upload', data=dict(
                name='new_cohort_name',
                project='wiki',
                csv=(StringIO(data), 'cohort.csv'),
                validate_as_user_ids='True',
                centralauth=False
            ))
        assert_true(not centralauth_called[0])
def setup_cohort_service():
    if request.endpoint is not None:
        if request.path.startswith('/cohorts'):
            cohort_service = getattr(g, 'cohort_service', None)
            tag_service = getattr(g, 'tag_service', None)
            centralauth_service = getattr(g, 'centralauth_service', None)
            if cohort_service is None:
                g.cohort_service = CohortService()
            if tag_service is None:
                g.tag_service = TagService()
            if centralauth_service is None:
                g.centralauth_service = CentralAuthService()
    def test_upload_with_centralauth_expansion_works(self):
        data = 'Actual validation tested elsewhere'
        centralauth_called = [False]

        def expand_via_ca_mock(cohort_users, session):
            assert_equal(cohort_users[0]['raw_id_or_name'], data)
            centralauth_called[0] = True
            return []

        ca_service_mock = CentralAuthService()
        ca_service_mock.expand_via_centralauth = expand_via_ca_mock
        with centralauth_service_set(app, ca_service_mock):
            response = self.app.post('/cohorts/upload', data=dict(
                name='new_cohort_name',
                project='wiki',
                csv=(StringIO(data), 'cohort.csv'),
                validate_as_user_ids='False',
                centralauth=True
            ))
        assert_true(centralauth_called[0])
        assert_equal(response.status_code, 302)
        assert_true(response.data.find('href="/cohorts/#') >= 0)
Exemple #5
0
    def test_upload_with_centralauth_expansion_works(self):
        data = 'Actual validation tested elsewhere'
        centralauth_called = [False]

        def expand_via_ca_mock(cohort_users, session):
            assert_equal(cohort_users[0]['raw_id_or_name'], data)
            centralauth_called[0] = True
            return []

        ca_service_mock = CentralAuthService()
        ca_service_mock.expand_via_centralauth = expand_via_ca_mock
        with centralauth_service_set(app, ca_service_mock):
            response = self.app.post('/cohorts/upload',
                                     data=dict(name='new_cohort_name',
                                               project='wiki',
                                               csv=(StringIO(data),
                                                    'cohort.csv'),
                                               validate_as_user_ids='False',
                                               centralauth=True))
        assert_true(centralauth_called[0])
        assert_equal(response.status_code, 302)
        assert_true(response.data.find('href="/cohorts/#') >= 0)
Exemple #6
0
def setup_filemanager():
    if request.endpoint is not None:
        if request.path.startswith('/reports'):
            file_manager = getattr(g, 'file_manager', None)
            if file_manager is None:
                g.file_manager = PublicReportFileManager(
                    app.logger,
                    app.absolute_path_to_app_root)
        cohort_service = getattr(g, 'cohort_service', None)
        centralauth_service = getattr(g, 'centralauth_service', None)
        if cohort_service is None:
            g.cohort_service = CohortService()
        if centralauth_service is None:
                g.centralauth_service = CentralAuthService()
Exemple #7
0
 def setUp(self):
     DatabaseTest.setUp(self)
     self.expand = CentralAuthService().expand_via_centralauth