tests.HttpTest.testNotRoot()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
cc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
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 1
class HttpTest(PPPTestCase(app)):
7 1
    config_var = 'PPP_CORE_CONFIG'
8 1
    config = """
9
    {
10
        "debug": true,
11
        "modules": []
12
    }
13
    """
14 1
    def testPostOnly(self):
15 1
        self.assertEqual(self.app.get('/', status='*').status_int, 405)
16 1
        self.assertEqual(self.app.put('/', status='*').status_int, 405)
17 1
    def testNotRoot(self):
18 1
        self.assertEqual(self.app.post_json('/foo', {}, status='*').status_int, 400)
19 1
    def testNotJson(self):
20 1
        self.assertEqual(self.app.post('/', 'foobar', status='*').status_int, 400)
21 1
    def testWorking(self):
22 1
        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 1
        self.assertResponse(q, [])
28 1
    def testNoTree(self):
29 1
        q = {'language': 'en'}
30
        self.assertStatusInt(q, 400)
31