コード例 #1
0
ファイル: test_entity.py プロジェクト: nomed/openspending
 def test_entity_as_json(self):
     entity = self._make_one(name="Test Entity", label="Test Entity Label")
     response = self.app.get(url(controller='entity',
                                 id=str(entity['_id']),
                                 action='view',
                                 format='json'))
     h.assert_equal(response._status, '200 OK')
     h.assert_equal(response._headers['Content-Type'], 'application/json')
     h.assert_true('"name": "Test Entity",' in response._body,
                     'json fragment not found. got: %s' % response._body)
コード例 #2
0
ファイル: test_classifier.py プロジェクト: nomed/openspending
    def test_view_entries_csv(self):
        classifier = self.db['classifier'].find_one({'taxonomy': 'cofog',
                                                     'name': '03'})

        url_ = url(controller='classifier', action='entries', format='csv',
                   taxonomy=classifier['taxonomy'],
                   name=classifier['name'])
        result = self.app.get(url_)

        h.assert_equal(result.status, '200 OK')
        h.assert_equal(result.content_type, 'text/csv')
        h.assert_true(result.body.startswith('_id,amount,'))  # csv headers
コード例 #3
0
ファイル: test_classifier.py プロジェクト: nomed/openspending
    def test_view_entries_html(self):
        classifier = self.db['classifier'].find_one({'taxonomy': 'cofog',
                                                     'name': '03'})

        url_ = url(controller='classifier', action='entries', format='html',
                   taxonomy=classifier['taxonomy'],
                   name=classifier['name'])
        result = self.app.get(url_)
        h.assert_equal(result.status, '200 OK')
        h.assert_equal(result.content_type, 'text/html')
        h.assert_true(('<h2 class="page-title">Public order and '
                         'safety: Entries</h2>') in result)
        h.assert_equal(result.body.count('full entry'), 5)
コード例 #4
0
ファイル: test_entity.py プロジェクト: nomed/openspending
    def test_common_pageview(self):
        h.skip_if_stubbed_solr()

        entity = self._make_one(name="Test Entity", label="Test Entity Label")
        response = self.app.get(url(controller='entity',
                                    id=str(entity['_id']),
                                    slug='test-entity-label',
                                    action='view'))
        h.assert_equal(response._status, '200 OK')
        h.assert_true('Test Entity Label' in response)
        json_name = '%s.json' % entity['_id']
        h.assert_true(json_name in response,
                        'Entity json "%s" not found in output' % json_name)
コード例 #5
0
ファイル: test_entity.py プロジェクト: nomed/openspending
    def test_browser_for_entity(self):
        h.skip_if_stubbed_solr()

        from openspending.model import Dataset, Entry

        dataset = Dataset(name='testdataset')
        Dataset.c.save(dataset, manipulate=True)
        dataset_ref_dict = dataset.to_ref_dict()

        entity = self._make_one(name="Test Entity", label="Test Entity Label")
        entity_ref_dict = entity.to_ref_dict()

        entry = {'name': 'Test Entry',
                 'label': 'Test Entry Label',
                 'from': entity_ref_dict,
                 'to': entity_ref_dict,
                 'amount': 10.0,
                 'dataset': dataset_ref_dict}
        Entry.c.save(entry)

        h.clean_and_reindex_solr()

        entity_url = url(controller='entity', id=str(entity['_id']),
                         slug='test-entity-label', action='view')
        response = self.app.get(entity_url)

        h.assert_equal(response._status, '200 OK')
        h.assert_true('<b>1 entries</b> found.<br />' in response)
        h.assert_true('entries.json">' in response)
        h.assert_true('entries.csv">' in response)
コード例 #6
0
ファイル: test_classifier.py プロジェクト: nomed/openspending
    def test_view_by_taxonomy_name_html(self):
        classifier = self.db['classifier'].find_one({'taxonomy': 'cofog',
                                                     'name': '03'})
        url_ = classifier_url(classifier)
        result = self.app.get(url_)

        h.assert_equal(result.status, '200 OK')

        # Links to entries json and csv and entries listing
        h.assert_true('<a href="/classifier/cofog/03/entries.json">'
                        in result)
        h.assert_true('<a href="/classifier/cofog/03/entries.csv">'
                        in result)
        h.assert_true('<a href="/classifier/cofog/03/entries">Search</a>'
                        in result)

        # Search box and result listing from the solr browser
        h.assert_true('class="search-form' in result)
        h.assert_equal(result.body.count('full entry'), 5)