tests.test_activities   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B TestActivities.test_get_filter_activities() 0 38 5
1
from .base import BaseTestCase
2
3
4
class TestActivities(BaseTestCase):
5
6
    def test_get_filter_activities(self):
7
        res = self.nxc.get_activities()
8
        all_data = res.data
9
        assert res.is_ok
10
11
        # test limit
12
        res = self.nxc.get_activities(limit=1)
13
        assert res.is_ok
14
        assert len(res.data) <= 1
15
16
        # test ascending sorting
17
        res = self.nxc.get_activities(sort="asc")
18
        assert res.is_ok
19
        data = res.data
20
        for num in range(1, len(data)):
21
            assert data[num - 1]['activity_id'] <= data[num]['activity_id']
22
23
        # test descending sorting
24
        res = self.nxc.get_activities(sort="desc")
25
        assert res.is_ok
26
        data = res.data
27
        for num in range(1, len(data)):
28
            assert data[num - 1]['activity_id'] >= data[num]['activity_id']
29
30
        # TODO: add more reliable tests for since, object_id, object_type parameters, if WebDAV Directory API will be
31
        #  implemented and it will be possible to make files manipulation to create activities from api
32
33
        # not reliable test for filter by object_id and object_type
34
        if len(all_data):
35
            object_to_filter_by = all_data[0]
36
            res = self.nxc.get_activities(object_id=object_to_filter_by['object_id'],
37
                                          object_type=object_to_filter_by['object_type'])
38
            assert res.is_ok
39
            data = res.data
40
            assert len(data) >= 1
41
            for each in data:
42
                assert each['object_id'] == object_to_filter_by['object_id']
43
                assert each['object_type'] == object_to_filter_by['object_type']
44