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

uwefladrich / scriptengine-tasks-ecearth / 22106609031

17 Feb 2026 04:26PM UTC coverage: 97.05% (-0.04%) from 97.085%
22106609031

push

github

valentinaschueller
Move get_template into helpers.files (#116)

23 of 24 new or added lines in 5 files covered. (95.83%)

2 existing lines in 2 files now uncovered.

2270 of 2339 relevant lines covered (97.05%)

0.97 hits per line

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

95.35
/tests/test_gitlab.py
1
"""Tests for monitoring/gitlab.py"""
2

3
from unittest.mock import Mock, patch
1✔
4

5
import pytest
1✔
6
import scriptengine.exceptions
1✔
7

8
from monitoring.gitlab import Gitlab, create_anchor
1✔
9

10

11
def test_gitlab_presentation_list(tmp_path):
1✔
12
    init = {
1✔
13
        "src": str(tmp_path),
14
        "local_dst": str(tmp_path),
15
        "template": str(tmp_path / "gitlab.txt.j2"),
16
        "subject": "Test Issue",
17
        "api_key": "Invalid Key",
18
    }
19
    redmine_task = Gitlab(init)
1✔
20
    test_sources = ["path.txt", {"path": "path.txt"}, "path.yml"]
1✔
21
    with patch.object(redmine_task, "log_warning") as mock:
1✔
22
        result = redmine_task.get_presentation_list(test_sources, str(tmp_path))
1✔
23
    mock.assert_called_with("Can not present diagnostic: File not found: path.yml")
1✔
24
    assert result == []
1✔
25

26

27
def test_gitlab_connection_error(tmp_path):
1✔
28
    init = {
1✔
29
        "src": str(tmp_path),
30
        "local_dst": str(tmp_path),
31
        "template": str(tmp_path / "gitlab.txt.j2"),
32
        "subject": "Test Issue",
33
        "api_key": "Invalid Key",
34
    }
35
    gitlab_task = Gitlab(init)
1✔
36
    pytest.raises(
1✔
37
        scriptengine.exceptions.ScriptEngineTaskRunError,
38
        gitlab_task.get_project_and_issue,
39
        init["api_key"],
40
        init["subject"],
41
    )
42

43

44
def test_gitlab_auth_error(tmp_path):
1✔
45
    init = {
1✔
46
        "src": str(tmp_path),
47
        "local_dst": str(tmp_path),
48
        "template": str(tmp_path / "gitlab.txt.j2"),
49
        "subject": "Test Issue",
50
        "api_key": "Invalid Key",
51
    }
52
    gitlab_task = Gitlab(init)
1✔
53
    pytest.raises(
1✔
54
        scriptengine.exceptions.ScriptEngineTaskRunError,
55
        gitlab_task.get_project_and_issue,
56
        init["api_key"],
57
        init["subject"],
58
    )
59

60

61
class MockTemplateOrIssue:
1✔
62
    def __init__(self):
1✔
63
        self.globals = {}
1✔
64
        self.web_url = ""
1✔
65

66
    def render(self, **kwargs):
1✔
UNCOV
67
        return str(kwargs)
×
68

69
    def save(self):
1✔
70
        return None
1✔
71

72
    def upload(self, file_name, filepath=""):
1✔
73
        return f"![{file_name}]({filepath})"
×
74

75

76
def test_gitlab_run(tmp_path):
1✔
77
    init = {
1✔
78
        "src": str(tmp_path),
79
        "local_dst": str(tmp_path),
80
        "template": "./docs/templates/gitlab.txt.j2",
81
        "subject": "Test Issue",
82
        "api_key": "Invalid Key",
83
    }
84
    gitlab_task = Gitlab(init)
1✔
85
    gitlab_task.get_presentation_list = Mock(return_value=[])
1✔
86
    mock_object = MockTemplateOrIssue()
1✔
87
    gitlab_task.get_project_and_issue = Mock(return_value=(mock_object, mock_object))
1✔
88
    with patch.object(gitlab_task, "log_debug") as mock:
1✔
89
        gitlab_task.run(init)
1✔
90
    mock.assert_called_with("Saving issue.")
1✔
91

92

93
def test_create_anchor():
1✔
94
    test_string = "Precipitation - Evaporation (Annual Mean Climatology)"
1✔
95
    gitlab_anchor = "precipitation-evaporation-annual-mean-climatology"
1✔
96
    assert create_anchor(test_string) == gitlab_anchor
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