Passed
Pull Request — master (#15)
by
unknown
01:06
created

tests.test_activities   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 31
dl 0
loc 46
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B TestActivities.test_get_filter_activities() 0 38 5
1
from .base import BaseTestCase
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
4
class TestActivities(BaseTestCase):
5
6
    SUCCESS_CODE = 200
7
8
    def test_get_filter_activities(self):
9
        res = self.nxc.get_activities()
10
        all_data = res['ocs']['data']
11
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
12
13
        # test limit
14
        res = self.nxc.get_activities(limit=1)
15
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
16
        assert len(res['ocs']['data']) <= 1
17
18
        # test ascending sorting
19
        res = self.nxc.get_activities(sort="asc")
20
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
21
        data = res['ocs']['data']
22
        for num in range(1, len(data)):
23
            assert data[num - 1]['activity_id'] <= data[num]['activity_id']
24
25
        # test descending sorting
26
        res = self.nxc.get_activities(sort="desc")
27
        assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
28
        data = res['ocs']['data']
29
        for num in range(1, len(data)):
30
            assert data[num - 1]['activity_id'] >= data[num]['activity_id']
31
32
        # TODO: add more reliable tests for since, object_id, object_type parameters, if WebDAV Directory API will be
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
33
        #  implemented and it will be possible to make files manipulation to create activities from api
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
34
35
        # not reliable test for filter by object_id and object_type
36
        if len(all_data):
37
            object_to_filter_by = all_data[0]
38
            res = self.nxc.get_activities(object_id=object_to_filter_by['object_id'],
39
                                          object_type=object_to_filter_by['object_type'])
40
            assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE
41
            data = res['ocs']['data']
42
            assert len(data) >= 1
43
            for each in data:
44
                assert each['object_id'] == object_to_filter_by['object_id']
45
                assert each['object_type'] == object_to_filter_by['object_type']
46
0 ignored issues
show
coding-style introduced by
Trailing newlines
Loading history...
47