root/pdw/tests/functional/test_api.py @ 325:61a8069c7b94

Revision 325:61a8069c7b94, 1.7 KB (checked in by acracia, 6 months ago)

changes to the api page, not taking the input and processing it with the calculators.
several other changes added to the model to process from dicts and to dicts

Line 
1import json
2from pdw.tests import *
3
4class TestApiController(TestController):
5
6    def test_index(self):
7        response = self.app.get(url(controller='api', action='index'))
8        assert 'API' in response
9
10    def test_pd(self):
11        params = {
12            'work' : {
13                'title': 'A Christmas Carol'},
14            'jurisdiction': 'netherlands'
15        }
16        params_json = json.dumps(params)
17        response = self.app.get(url(controller='api', action='pd'),
18            params={'q':params_json})
19        assert 'pd_probability' in response, response
20
21
22    def test_pd_from_db(self):
23        params_json = json.dumps({
24                "work": {
25                          "date": "19030101", 
26                          "persons": [
27                                      {
28                                                    "birth_date": "17490101", 
29                                                    "country": "uk", 
30                                                    "death_date": "None", 
31                                                    "type": "person", 
32                                                    "name": "Boyle, James"
33                                                  }
34                                    ], 
35                          "type": "photograph", 
36                          "title": "Collected Papers on the Public Domain (ed)"
37                        }, 
38                "jurisdiction": "ca"
39              })
40        response = self.app.get(url(controller='api', 
41                                    action='pd'),
42                                params={'q':params_json})
43           
44        assert 'pd_probability' in response
45
Note: See TracBrowser for help on using the browser.