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

popstas / google-drive-access / 21766298195

06 Feb 2026 09:19PM UTC coverage: 59.19% (-0.02%) from 59.206%
21766298195

push

github

popstas
fix(http): use self.translate for 404 fallback

translate(language, ...) referenced undefined local;
use self.translate() which reads self.language.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

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

1594 of 2693 relevant lines covered (59.19%)

0.59 hits per line

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

36.36
/src/drive_audit/http/handler.py
1
"""HTTP handler for managing Google Drive access."""
2

3
import json
1✔
4
from typing import Any, Dict, List
1✔
5

6
from loguru import logger
1✔
7

8
from ..http_utils import JsonRequestHandler, LocalizedError
1✔
9
from ..model import DriveConfig, HttpConfig
1✔
10
from ..planfix_client import PlanfixClient
1✔
11
from . import create_client_folder as create_client_folder_route
1✔
12
from . import set_client_folder_access as set_client_folder_access_route
1✔
13
from . import share_file as share_file_route
1✔
14

15

16
def create_handler(
1✔
17
    planfix_client: PlanfixClient,
18
    service,
19
    http_config: HttpConfig,
20
    drive_config: DriveConfig,
21
    role: str,
22
    share_file_config=None,
23
):
24
    handler_http_config = http_config
1✔
25
    handler_language = http_config.lang
1✔
26

27
    class AccessHandler(JsonRequestHandler):
1✔
28
        http_config = handler_http_config
1✔
29
        language = handler_language
1✔
30

31
        def _log_request(self, payload: Dict[str, Any]) -> None:
1✔
32
            logger.info(
×
33
                "{} request: {}", self.path, json.dumps(payload, ensure_ascii=False)
34
            )
35

36
        def _format_accounts(self, accounts: List[str]) -> str:
1✔
37
            return ", ".join(accounts) if accounts else self.translate("none")
1✔
38

39
        def do_POST(self) -> None:  # noqa: N802
1✔
40
            if self.path == "/set_client_folder_access":
×
41
                if not self.authenticate():
×
42
                    return
×
43

44
                try:
×
45
                    payload = self.parse_json_body()
×
46
                except LocalizedError as exc:
×
47
                    self.send_json(
×
48
                        200, {"answer": self.translate(exc.key, **exc.context)}
49
                    )
50
                    return
×
51

52
                self._log_request(payload)
×
53
                set_client_folder_access_route.handle(
×
54
                    self,
55
                    payload,
56
                    planfix_client=planfix_client,
57
                    service=service,
58
                    drive_config=drive_config,
59
                    role=role,
60
                )
61
                return
×
62

63
            if self.path == "/create_client_folder":
×
64
                if not self.authenticate():
×
65
                    return
×
66

67
                try:
×
68
                    payload = self.parse_json_body()
×
69
                except LocalizedError as exc:
×
70
                    self.send_json(
×
71
                        200, {"answer": self.translate(exc.key, **exc.context)}
72
                    )
73
                    return
×
74

75
                self._log_request(payload)
×
76
                create_client_folder_route.handle(
×
77
                    self,
78
                    payload,
79
                    planfix_client=planfix_client,
80
                    service=service,
81
                    drive_config=drive_config,
82
                    role=role,
83
                )
84
                return
×
85

86
            if self.path == "/share_file":
×
87
                if not self.authenticate():
×
88
                    return
×
89

90
                try:
×
91
                    payload = self.parse_json_body()
×
92
                except LocalizedError as exc:
×
93
                    self.send_json(
×
94
                        200, {"answer": self.translate(exc.key, **exc.context)}
95
                    )
96
                    return
×
97

98
                self._log_request(payload)
×
99
                share_file_route.handle(
×
100
                    self,
101
                    payload,
102
                    service=service,
103
                    drive_config=drive_config,
104
                    share_file_config=share_file_config,
105
                )
106
                return
×
107

NEW
108
            self.send_json(200, {"answer": self.translate("not_found")})
×
109

110
    return AccessHandler
1✔
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

© 2026 Coveralls, Inc