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

popstas / google-drive-access / 21943951424

12 Feb 2026 10:58AM UTC coverage: 59.491% (-0.04%) from 59.534%
21943951424

push

github

popstas
feat(http): add folder_url to response, lang arg

Add folder_url to granted_existing translation and JSON response
in set_client_folder_access and create_client_folder routes.

Add per-request lang override via payload field across all routes.

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

2 of 8 new or added lines in 3 files covered. (25.0%)

1 existing line in 1 file now uncovered.

1614 of 2713 relevant lines covered (59.49%)

0.59 hits per line

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

71.43
/src/drive_audit/http/create_client_folder.py
1
"""Route handler for creating client folders."""
2

3
from typing import Any, Dict
1✔
4

5
from loguru import logger
1✔
6

7
from ..access_service import (
1✔
8
    create_client_folder,
9
    get_task_and_assignees,
10
    grant_access,
11
)
12
from ..http_utils import LocalizedError
1✔
13

14

15
def handle(handler, payload, *, planfix_client, service, drive_config, role):
1✔
16
    """Handle the /create_client_folder route."""
17
    required_fields = ["contact_id", "folder_name"]
1✔
18
    missing_fields = [field for field in required_fields if field not in payload]
1✔
19
    if missing_fields:
1✔
20
        handler.send_json(
×
21
            200,
22
            {
23
                "answer": handler.translate(
24
                    "missing_fields", fields=", ".join(missing_fields)
25
                )
26
            },
27
        )
28
        return
×
29

30
    try:
1✔
31
        contact_id = int(payload["contact_id"])
1✔
32
        folder_name = str(payload["folder_name"]).strip()
1✔
33
        folder_name_words = folder_name.split()
1✔
34
        name_warning = ""
1✔
35
        if len(folder_name_words) == 1:
1✔
36
            name_warning = " \n" + handler.translate("folder_name_single_word")
1✔
37
        task_id, initial_assignee_ids = get_task_and_assignees(
1✔
38
            planfix_client, contact_id
39
        )
40
        folder, created = create_client_folder(service, drive_config, folder_name)
1✔
41
        access_report = grant_access(
1✔
42
            planfix_client,
43
            service,
44
            drive_config,
45
            role,
46
            task_id,
47
            initial_assignee_ids,
48
            folder["id"],
49
        )
50
    except LocalizedError as exc:
×
51
        handler.send_json(200, {"answer": handler.translate(exc.key, **exc.context)})
×
52
        return
×
53
    except Exception as exc:  # pylint: disable=broad-except
×
54
        logger.exception("Failed to process request: {}", exc)
×
55
        handler.send_json(200, {"answer": handler.translate("internal_server_error")})
×
56
        return
×
57

58
    granted_accounts = access_report["granted_accounts"]
1✔
59
    existing_accounts = access_report["existing_accounts"]
1✔
60
    folder_url = f"https://drive.google.com/drive/folders/{folder['id']}"
1✔
61
    answer = handler.translate(
1✔
62
        "granted_existing",
63
        granted=handler._format_accounts(granted_accounts),
64
        existing=handler._format_accounts(existing_accounts),
65
        folder_url=folder_url,
66
    )
67
    if created:
1✔
UNCOV
68
        answer_text = (
×
69
            handler.translate(
70
                "folder_created",
71
                folder_name=folder_name,
72
                details=answer,
73
                folder_url=folder_url,
74
            )
75
            + name_warning
76
        )
77
    else:
78
        answer_text = (
1✔
79
            handler.translate(
80
                "client_folder_exists",
81
                folder_url=folder_url,
82
                details=answer,
83
            )
84
            + name_warning
85
        )
86
    handler.send_json(
1✔
87
        200,
88
        {
89
            "answer": answer_text,
90
            "folder_id": folder["id"],
91
            "folder_url": folder_url,
92
            "granted_accounts": granted_accounts,
93
            "existing_accounts": existing_accounts,
94
        },
95
    )
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