コード例 #1
0
    def test_user_consent(self):
        self.shallow_org_tree()
        org1, org2 = [
            org
            for org in Organization.query.filter(Organization.id > 0).limit(2)
        ]

        audit = Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID)
        uc1 = UserConsent(organization_id=org1.id,
                          user_id=TEST_USER_ID,
                          agreement_url=self.url,
                          audit=audit)
        uc2 = UserConsent(organization_id=org2.id,
                          user_id=TEST_USER_ID,
                          agreement_url=self.url,
                          audit=audit)
        uc1.staff_editable = True
        uc1.send_reminders = False
        uc2.staff_editable = True
        uc2.send_reminders = False
        with SessionScope(db):
            db.session.add(uc1)
            db.session.add(uc2)
            db.session.commit()
        self.test_user = db.session.merge(self.test_user)
        self.login()
        rv = self.client.get('/api/user/{}/consent'.format(TEST_USER_ID))
        self.assert200(rv)
        self.assertEquals(len(rv.json['consent_agreements']), 2)
        self.assertTrue(
            'send_reminders' not in rv.json['consent_agreements'][0])
        self.assertTrue('staff_editable' in rv.json['consent_agreements'][0])
コード例 #2
0
    def test_user_consent(self):
        self.shallow_org_tree()
        org1, org2 = [org for org in Organization.query.filter(
            Organization.id > 0).limit(2)]

        audit = Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID)
        uc1 = UserConsent(
            organization_id=org1.id, user_id=TEST_USER_ID,
            agreement_url=self.url, audit=audit)
        uc2 = UserConsent(
            organization_id=org2.id, user_id=TEST_USER_ID,
            agreement_url=self.url, audit=audit)
        uc1.staff_editable = True
        uc1.send_reminders = False
        uc2.staff_editable = True
        uc2.send_reminders = False
        uc2.status = 'suspended'
        with SessionScope(db):
            db.session.add(uc1)
            db.session.add(uc2)
            db.session.commit()
        self.test_user = db.session.merge(self.test_user)
        self.login()
        response = self.client.get('/api/user/{}/consent'.format(TEST_USER_ID))
        assert response.status_code == 200
        assert len(response.json['consent_agreements']) == 2
        assert 'send_reminders' not in response.json['consent_agreements'][0]
        assert 'staff_editable' in response.json['consent_agreements'][0]
        org1, org2 = db.session.merge(org1), db.session.merge(org2)
        org1_consent = [ca for ca in response.json[
            'consent_agreements'] if ca['organization_id'] == org1.id][0]
        org2_consent = [ca for ca in response.json[
            'consent_agreements'] if ca['organization_id'] == org2.id][0]
        assert org1_consent['status'] == 'consented'
        assert org2_consent['status'] == 'suspended'
コード例 #3
0
    def test_user_consent(self):
        self.shallow_org_tree()
        org1, org2 = [
            org
            for org in Organization.query.filter(Organization.id > 0).limit(2)
        ]

        audit = Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID)
        uc1 = UserConsent(organization_id=org1.id,
                          user_id=TEST_USER_ID,
                          agreement_url=self.url,
                          audit=audit)
        uc2 = UserConsent(organization_id=org2.id,
                          user_id=TEST_USER_ID,
                          agreement_url=self.url,
                          audit=audit)
        uc1.staff_editable = True
        uc1.send_reminders = False
        uc2.staff_editable = True
        uc2.send_reminders = False
        uc2.status = 'suspended'
        with SessionScope(db):
            db.session.add(uc1)
            db.session.add(uc2)
            db.session.commit()
        self.test_user = db.session.merge(self.test_user)
        self.login()
        response = self.client.get('/api/user/{}/consent'.format(TEST_USER_ID))
        assert response.status_code == 200
        assert len(response.json['consent_agreements']) == 2
        assert 'send_reminders' not in response.json['consent_agreements'][0]
        assert 'staff_editable' in response.json['consent_agreements'][0]
        assert response.json['consent_agreements'][0]['status'] == 'consented'
        assert response.json['consent_agreements'][1]['status'] == 'suspended'