Completed
Push — master ( 0b5289...e5d674 )
by Matěj
11s queued 10s
created

tests.test_notifications   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestNotifications.test_get_delete_notifications() 0 25 2
1
from .base import BaseTestCase
2
3
4
class TestNotifications(BaseTestCase):
5
6
    SUCCESS_CODE = 200
7
8
    def test_get_delete_notifications(self):
9
        # get all notifications
10
        res = self.nxc.get_notifications()
11
        all_data = res['ocs']['data']
12
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
13
14
        if len(all_data):
15
            notification = all_data[0]
16
17
            # get single notification
18
            res = self.nxc.get_notification(notification['notification_id'])
19
            assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
20
            assert res['ocs']['data']['notification_id'] == notification['notification_id']
21
22
            # delete single notification
23
            res = self.nxc.delete_notification(notification['notification_id'])
24
            assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
25
        else:
26
            # assert get single notification will return 404 not found
27
            res = self.nxc.get_notification(1)
28
            assert res['ocs']['meta']['statuscode'] == self.NOT_FOUND_CODE
29
30
        # delete all notifications success code check
31
        res = self.nxc.delete_all_notifications()
32
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
33
34
        # TODO: add more tests if WebDAV api will be implemented and there will be ability to make actions
35
        #  using api which creates notifications (mentions in comments)
36
        #  or when Federated file sharings api will be implemented (harder way)
37
38
39
40