Esempio n. 1
0
    def test_moleculescsv_somecols(self):
        csv = StringIO()
        csv.write('bla')
        job = self.fake_job()
        job.db.molecules2csv.return_value = csv
        request = testing.DummyRequest(params={
            'start': 0,
            'limit': 10,
            'cols': '["name","score"]'
        })

        views = JobViews(job, request)
        rows = [{'name': 'foo', 'score': 'bar', 'id': 123}]
        views.moleculesjson = Mock(return_value={'rows': rows})

        views.moleculescsv()

        job.db.molecules2csv.assert_called_with(rows, cols=['name', 'score'])
Esempio n. 2
0
    def test_moleculescsv(self):
        csv = StringIO()
        csv.write('bla')
        job = self.fake_job()
        job.db.molecules2csv.return_value = csv
        request = testing.DummyRequest(params={'start': 0, 'limit': 10})
        views = JobViews(job, request)
        views.moleculesjson = Mock(return_value={'rows': []})

        response = views.moleculescsv()

        self.assertEqual(response.content_type, 'text/csv')
        self.assertEqual(response.body, b'bla')