Completed
Pull Request — master (#20)
by Valentin
02:37 queued 01:31
created

tests.HttpTest.testNotRoot()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
cc 1
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
1
"""Test HTTP capabilities of the core's frontend."""
2
3 1
from ppp_libmodule.tests import PPPTestCase
4 1
from ppp_core import app
5
6
class HttpTest(PPPTestCase(app)):
7
    config_var = 'PPP_CORE_CONFIG'
8
    config = """
9
    {
10
        "debug": true,
11
        "modules": []
12
    }
13
    """
14
    def testPostOnly(self):
15
        self.assertEqual(self.app.get('/', status='*').status_int, 405)
16
        self.assertEqual(self.app.put('/', status='*').status_int, 405)
17
    def testNotRoot(self):
18
        self.assertEqual(self.app.post_json('/foo', {}, status='*').status_int, 400)
19
    def testNotJson(self):
20
        self.assertEqual(self.app.post('/', 'foobar', status='*').status_int, 400)
21
    def testWorking(self):
22
        q = {'id': '1', 'language': 'en', 'tree': {'type': 'triple',
23
             'subject': {'type': 'resource', 'value': 'foo'},
24
             'predicate': {'type': 'resource', 'value': 'bar'},
25
             'object': {'type': 'resource', 'value': 'baz'}},
26
              'measures': {}, 'trace': []}
27
        self.assertResponse(q, [])
28
    def testNoTree(self):
29
        q = {'language': 'en'}
30
        self.assertStatusInt(q, 400)
31