• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

maxtepkeev / python-redmine / 317

pending completion
317

push

travis-ci-com

maxtepkeev
version bump

1 of 1 new or added line in 1 file covered. (100.0%)

1366 of 1366 relevant lines covered (100.0%)

8.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/redminelib/managers/standard.py
1
"""
2
Defines standard Redmine resources managers.
3
"""
4

5
from . import ResourceManager
8✔
6
from .. import exceptions
8✔
7

8

9
class ProjectManager(ResourceManager):
8✔
10
    def __getattr__(self, attr):
8✔
11
        if attr in ('close', 'reopen', 'archive', 'unarchive'):
8✔
12
            if self.redmine.ver is not None and self.redmine.ver < (5, 0, 0):
8✔
13
                raise exceptions.VersionMismatchError(f'Project {attr}')
8✔
14

15
            return lambda resource_id: self.redmine.engine.request(
8✔
16
                'put', f'{self.redmine.url}{self.resource_class.query_one.format(resource_id)[:-5]}/{attr}.json')
17

18
        raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{attr}'")
8✔
19

20

21
class FileManager(ResourceManager):
8✔
22
    def _process_create_response(self, request, response):
8✔
23
        if response is True:
8✔
24
            response = {self.container: {'id': int(request[self.container]['token'].split('.')[0])}}
8✔
25

26
        return super()._process_create_response(request, response)
8✔
27

28

29
class WikiPageManager(ResourceManager):
8✔
30
    def _process_create_response(self, request, response):
8✔
31
        if response is True:
8✔
32
            raise exceptions.ValidationError('Resource already exists')  # issue #182
8✔
33

34
        return super()._process_create_response(request, response)
8✔
35

36

37
class UserManager(ResourceManager):
8✔
38
    @staticmethod
8✔
39
    def _check_custom_url(path):
5✔
40
        if path.endswith('/me.json'):
8✔
41
            path = '/my/account.json'
8✔
42

43
        return path
8✔
44

45
    def _construct_get_url(self, path):
8✔
46
        return super()._construct_get_url(self._check_custom_url(path))
8✔
47

48
    def _prepare_create_request(self, request):
8✔
49
        request = super()._prepare_create_request(request)
8✔
50
        request['send_information'] = request[self.container].pop('send_information', False)
8✔
51
        return request
8✔
52

53
    def _construct_update_url(self, path):
8✔
54
        return super()._construct_update_url(self._check_custom_url(path))
8✔
55

56
    def _prepare_update_request(self, request):
8✔
57
        request = super()._prepare_update_request(request)
8✔
58
        request['send_information'] = request[self.resource_class.container_update].pop('send_information', False)
8✔
59
        return request
8✔
60

61

62
class NewsManager(ResourceManager):
8✔
63
    def _process_create_response(self, request, response):
8✔
64
        if response is True:
8✔
65
            response = {self.container: self.redmine.news.filter(**self.params)[0].raw()}
8✔
66

67
        return super()._process_create_response(request, response)
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc