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

RAMP-project / RAMP / 9364900772

04 Jun 2024 09:46AM UTC coverage: 77.375%. First build
9364900772

Pull #150

github

web-flow
Merge df93fb41e into 8b66734bb
Pull Request #150: Release v0.5.2

285 of 316 new or added lines in 17 files covered. (90.19%)

1409 of 1821 relevant lines covered (77.38%)

0.77 hits per line

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

97.3
/tests/test_cli.py
1
import os
1✔
2
import shutil
1✔
3

4
import mock
1✔
5
import matplotlib.pyplot as plt
1✔
6
import pytest
1✔
7
from ramp.cli import parser as ramp_parser, main as ramp_main
1✔
8
from .utils import TEST_PATH, TEST_OUTPUT_PATH
1✔
9

10

11
class TestProcessUserArguments:
1✔
12
    def setup_method(self):
1✔
13
        if os.path.exists(TEST_OUTPUT_PATH):
1✔
NEW
14
            shutil.rmtree(TEST_OUTPUT_PATH, ignore_errors=True)
×
15
        if os.path.exists(TEST_OUTPUT_PATH) is False:
1✔
16
            os.mkdir(TEST_OUTPUT_PATH)
1✔
17

18
    @mock.patch(
1✔
19
        "argparse.ArgumentParser.parse_args",
20
        return_value=ramp_parser.parse_args(
21
            ["--start-date", "2022-01-01", "-y", "2022"]
22
        ),
23
    )
24
    def test_impossible_option_combinaison_start_date_year(self, m_args):
1✔
25
        with pytest.raises(ValueError):
1✔
26
            ramp_main()
1✔
27

28
    @mock.patch(
1✔
29
        "argparse.ArgumentParser.parse_args",
30
        return_value=ramp_parser.parse_args(["--end-date", "2022-01-01", "-y", "2022"]),
31
    )
32
    def test_impossible_option_combinaison_end_date_year(self, m_args):
1✔
33
        with pytest.raises(ValueError):
1✔
34
            ramp_main()
1✔
35

36
    @mock.patch(
1✔
37
        "argparse.ArgumentParser.parse_args",
38
        return_value=ramp_parser.parse_args(
39
            [
40
                "-i",
41
                os.path.join(TEST_PATH, "test_inputs", "example_excel_usecase.xlsx"),
42
                "-y",
43
                "2022",
44
                "2023",
45
                "-o",
46
                os.path.join(TEST_OUTPUT_PATH, "example_excel.csv"),
47
            ]
48
        ),
49
    )
50
    def test_multiple_year_is_possible(self, m_args, monkeypatch):
1✔
51
        monkeypatch.setattr(
1✔
52
            plt, "show", lambda: None
53
        )  # prevents the test to output figure
54
        ramp_main()
1✔
55

56
    @mock.patch(
1✔
57
        "argparse.ArgumentParser.parse_args",
58
        return_value=ramp_parser.parse_args(
59
            [
60
                "-i",
61
                os.path.join(TEST_OUTPUT_PATH),
62
                "-y",
63
                "2022",
64
                "-n",
65
                "1",
66
            ]
67
        ),
68
    )
69
    def test_month_variation_without_month_files(self, m_args):
1✔
70
        with pytest.raises(ValueError):
1✔
71
            ramp_main()
1✔
72

73
    @mock.patch(
1✔
74
        "argparse.ArgumentParser.parse_args",
75
        return_value=ramp_parser.parse_args(
76
            [
77
                "-i",
78
                os.path.join(TEST_OUTPUT_PATH),
79
                "-y",
80
                "2022",
81
                "-n",
82
                "1",
83
            ]
84
        ),
85
    )
86
    def test_month_variation_with_month_files(self, m_args):
1✔
87
        for i in range(12):
1✔
88
            shutil.copy(
1✔
89
                os.path.join(TEST_PATH, "test_inputs", "example_excel_usecase.xlsx"),
90
                os.path.join(TEST_OUTPUT_PATH, f"example_excel_usecase_{i}.xlsx"),
91
            )
92
        ramp_main()
1✔
93

94
    def teardown_method(self):
1✔
95
        if os.path.exists(TEST_OUTPUT_PATH):
1✔
96
            shutil.rmtree(TEST_OUTPUT_PATH, ignore_errors=True)
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

© 2025 Coveralls, Inc