コード例 #1
0
ファイル: test_commands.py プロジェクト: seiteta/udata
 def test_toggle_badge_off(self):
     ps_badge = Badge(kind=PUBLIC_SERVICE)
     certified_badge = Badge(kind=CERTIFIED)
     org = OrganizationFactory(badges=[ps_badge, certified_badge])
     toggle(str(org.id), PUBLIC_SERVICE)
     org.reload()
     self.assertEqual(org.badges[0].kind, CERTIFIED)
コード例 #2
0
    def test_toggle_badge_off(self, cli):
        ps_badge = Badge(kind=PUBLIC_SERVICE)
        certified_badge = Badge(kind=CERTIFIED)
        org = OrganizationFactory(badges=[ps_badge, certified_badge])

        cli('badges', 'toggle', str(org.id), PUBLIC_SERVICE)

        org.reload()
        assert org.badges[0].kind == CERTIFIED
コード例 #3
0
ファイル: tests.py プロジェクト: rblmdst/udata-gouvfr
 def test_render_dataconnexions_6_with_data(self):
     # Use tags until we are sure all reuse are correctly labeled
     for tag, label, description in DATACONNEXIONS_6_CATEGORIES:
         badge = Badge(kind=DATACONNEXIONS_6_CANDIDATE)
         VisibleReuseFactory(tags=['dataconnexions-6', tag], badges=[badge])
     response = self.client.get(url_for('gouvfr.dataconnexions6'))
     self.assert200(response)
コード例 #4
0
ファイル: tests.py プロジェクト: rhanka/udata-gouvfr
    def test_public_services(self):
        ps_badge = Badge(kind=PUBLIC_SERVICE)
        public_services = [
            OrganizationFactory(badges=[ps_badge]) for _ in range(2)
        ]
        for _ in range(3):
            OrganizationFactory()

        assert PublicServicesMetric().get_value() == len(public_services)
コード例 #5
0
ファイル: test_site_metrics.py プロジェクト: rfResearch/udata
    def test_badges_metric(self, app):
        site = SiteFactory.create(id=app.config['SITE_ID'])

        ps_badge = Badge(kind=PUBLIC_SERVICE)
        public_services = [
            OrganizationFactory(badges=[ps_badge]) for _ in range(2)
        ]
        for _ in range(3):
            OrganizationFactory()

        site.count_org_for_badge(PUBLIC_SERVICE)

        assert site.get_metrics()[PUBLIC_SERVICE] == len(public_services)
コード例 #6
0
ファイル: test_site_views.py プロジェクト: mayjolux/udata
    def test_organizations_csv_with_filters(self):
        '''Should handle filtering but ignore paging or facets'''
        user = self.login()
        with self.autoindex():
            public_service_badge = Badge(kind=PUBLIC_SERVICE, created_by=user)
            filtered_orgs = [
                OrganizationFactory(badges=[public_service_badge])
                for _ in range(6)
            ]
            orgs = [OrganizationFactory() for _ in range(3)]
            hidden_org = OrganizationFactory(deleted=datetime.now())

        response = self.get(
            url_for('site.organizations_csv',
                    badge=PUBLIC_SERVICE,
                    page_size=3,
                    facets=True))

        self.assert200(response)
        self.assertEqual(response.mimetype, 'text/csv')
        self.assertEqual(response.charset, 'utf-8')

        csvfile = StringIO(response.data.decode('utf8'))
        reader = csv.get_reader(csvfile)
        header = next(reader)

        self.assertEqual(header[0], 'id')
        self.assertIn('name', header)
        self.assertIn('description', header)
        self.assertIn('created_at', header)
        self.assertIn('last_modified', header)
        self.assertIn('metric.datasets', header)

        rows = list(reader)
        ids = [row[0] for row in rows]

        # Should ignore paging
        self.assertEqual(len(rows), len(filtered_orgs))
        # SHoulf pass filter
        for org in filtered_orgs:
            self.assertIn(str(org.id), ids)
        for org in orgs:
            self.assertNotIn(str(org.id), ids)
        self.assertNotIn(str(hidden_org.id), ids)
コード例 #7
0
ファイル: tests.py プロジェクト: rblmdst/udata-gouvfr
 def test_render_dataconnexions_5_with_data(self):
     for tag, label, description in DATACONNEXIONS_5_CATEGORIES:
         badge = Badge(kind=DATACONNEXIONS_5_CANDIDATE)
         VisibleReuseFactory(tags=[tag], badges=[badge])
     response = self.client.get(url_for('gouvfr.dataconnexions5'))
     self.assert200(response)
コード例 #8
0
ファイル: tests.py プロジェクト: thioky/udata-gouvfr
 def test_render_with_data(self):
     for i in range(3):
         badge = Badge(kind=OPENFIELD16)
         VisibleDatasetFactory(badges=[badge])
     response = self.client.get(url_for('gouvfr.openfield16'))
     self.assert200(response)
コード例 #9
0
 def test_render_with_data(self):
     for i in range(3):
         badge = Badge(kind=SPD)
         VisibleDatasetFactory(badges=[badge])
     response = self.client.get(url_for('gouvfr.spd'))
     self.assert200(response)