예제 #1
0
    def test_get_pipeline_fields(self):

        app = MendeleyCache('mendeleycache')
        app.testing = True

        sut = app.test_client()
        """:type : FlaskClient"""

        # Fire fields versus an empty database
        response = sut.get('/fields', follow_redirects=True)
        """:type : Response"""

        self.assertEqual(response.status_code, 200)
        data = response.get_data(as_text=True)
        json_data = json.loads(data)
        self.assertEqual(len(json_data), 0)

        # Trigger the pipeline
        app.pipeline_controller.execute()

        # Fire fields versus a filled database
        response = sut.get('/fields', follow_redirects=True)
        """:type : Response"""

        self.assertEqual(response.status_code, 200)
        data = response.get_data(as_text=True)
        json_data = json.loads(data)
        self.assertEqual(len(json_data), 14)