1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
from opendc.util.database import DB
def test_get_authorizations_non_existing(client, mocker):
mocker.patch.object(DB, 'fetch_one', return_value=None)
mocker.patch.object(DB, 'fetch_all', return_value=None)
assert '404' in client.get('/api/v2/projects/1/authorizations').status
def test_get_authorizations_not_authorized(client, mocker):
mocker.patch.object(DB,
'fetch_one',
return_value={
'_id': '1',
'name': 'test trace',
'authorizations': [{
'projectId': '2',
'authorizationLevel': 'OWN'
}]
})
mocker.patch.object(DB, 'fetch_all', return_value=[])
res = client.get('/api/v2/projects/1/authorizations')
assert '403' in res.status
def test_get_authorizations(client, mocker):
mocker.patch.object(DB,
'fetch_one',
return_value={
'_id': '1',
'name': 'test trace',
'authorizations': [{
'projectId': '1',
'authorizationLevel': 'OWN'
}]
})
mocker.patch.object(DB, 'fetch_all', return_value=[])
res = client.get('/api/v2/projects/1/authorizations')
assert len(res.json['content']) == 0
assert '200' in res.status
|