Exemple #1
0
 def test_show_last_month_html(self, mock_browser):
     main("2017-08-17 came 9")
     main("show last month html")
     assert mock_browser.url.endswith(".html")
     with open(mock_browser.url) as f:
         s = f.read()
         assert "9:00" in s
Exemple #2
0
 def test_non_working_project(self):
     main("came 9 left 15:00 lunch 0m")
     main('project new "Parental leave" --no-work')
     s, _ = main("project Par 2")
     assert "02:00" in s  # Parental leave
     assert "06:00" in s  # EPG Program
     assert "00:15" in s  # Flex
     assert "--no-work" not in s
Exemple #3
0
 def test_wrong_sum(self, custom_log_path, mock_browser, mockdate_oct_24):
     custom_log_path(
         Path(os.path.realpath(__file__)).parent / "_fixtures" / "wrong_sum.yaml"
     )
     main("show week html")
     with open(mock_browser.url) as f:
         s = f.read()
         assert "1,25" not in s
         assert "25,25" in s
Exemple #4
0
    def test_remove(self, custom_log_path):
        custom_log_path(
            Path(os.path.realpath(__file__)).parent / "_fixtures" /
            "alias.yaml")
        main("alias --remove slw")
        out, err = main("alias")

        assert err == 0
        assert "slw" not in out
Exemple #5
0
    def test_add_alias(self, custom_log_path):
        custom_log_path(
            Path(os.path.realpath(__file__)).parent / "_fixtures" /
            "alias.yaml")
        main("alias hello came 7:45")

        _, err = main("hello")

        assert err == 0
Exemple #6
0
 def test_weekday(self):
     main("monday came 1")
     main("tuesday came 2")
     main("wednesday came 3")
     main("thursday came 4")
     s, _ = main("friday came 5")
     assert "01:00" in s
     assert "02:00" in s
     assert "03:00" in s
     assert "04:00" in s
     assert "05:00" in s
Exemple #7
0
    def test_unreadable_file(self, temp_yamlfile):
        temp_yamlfile.write("")

        err, code = main()

        assert "not readable. Remove it to create a new one." in err
        assert code == 1
Exemple #8
0
def test_use_alias_raises_no_error(custom_log_path):
    custom_log_path(
        Path(os.path.realpath(__file__)).parent / "_fixtures" / "alias.yaml")

    _, err = main("slw")

    assert err == 0
Exemple #9
0
    def test_not_working_path(self, non_existing_log_path):
        err, code = main()

        assert (
            "The directory for the specified path /does/not/exist does not exist."
            in err)
        assert code == 1
Exemple #10
0
 def test_show_week_has_javascript_and_buttons(self, mock_browser):
     s, _ = main("show week html")
     with open(mock_browser.url) as f:
         s = f.read()
         print(s)
         assert "<script" in s
         assert '<button onclick="copyToClipboard(' in s
Exemple #11
0
    def test_add_alias_but_no_definition_throws_error(self, custom_log_path):
        custom_log_path(
            Path(os.path.realpath(__file__)).parent / "_fixtures" /
            "alias.yaml")
        out, err = main("alias hello")

        assert err == 1
        assert "Error: new alias lacks definition." in out
Exemple #12
0
 def test_show_last_week_html(self, mock_browser):
     s, _ = main("show last week html")
     last_monday = str(
         timereporter.__main__.today() +
         timedelta(days=-timereporter.__main__.today().weekday(), weeks=-1))
     with open(mock_browser.url) as f:
         s = f.read()
         assert last_monday in s
Exemple #13
0
def test_list_aliases(custom_log_path):
    custom_log_path(
        Path(os.path.realpath(__file__)).parent / "_fixtures" / "alias.yaml")

    out, _ = main("alias")

    assert "slw" in out
    assert "show last week" in out
Exemple #14
0
 def test_report_time_on_two_projects(self):
     main('project new "EPG Support"')
     main('project new "EPG Maintenance"')
     main('project "EPG Support" 9')
     s, _ = main('project "EPG Maintenance" 8')
     assert "9:00" in s
     assert "8:00" in s
Exemple #15
0
def test_basic(mock_browser):
    main("9 16")
    main("yesterday 10 18")
    main("show december html --show-weekend")
    assert mock_browser.url.endswith(".html")
    with open(mock_browser.url) as f:
        s = f.read()
        assert "2016-12-01" in s
        assert "2016-12-31" in s
Exemple #16
0
 def test_show_week_html(self, mock_browser):
     main("came 9 left 16")
     main("yesterday came 10 left 18")
     main("show week html")
     assert mock_browser.url.endswith(".html")
     with open(mock_browser.url) as f:
         s = f.read()
         assert "7,00" in s
         assert "0,75" in s  # Used flex should be positive
         assert "23,25" not in s  # Used flex should show correctly
         assert "0,25" not in s  # Earned flex should not show
         assert "15,75" in s  # Sum of times
Exemple #17
0
 def test_came_followed_by_non_time_shall_give_readable_error_message(self):
     out, _ = main("came foo")
     assert 'Could not parse "foo" as time' in out
Exemple #18
0
 def test_last_weekday_multiple(self):
     main("last monday friday came 1")
     s, _ = main("show last week")
     assert s.count("01:00") == 2
Exemple #19
0
 def test_last_weekday(self):
     main("last monday came 1")
     main("last friday came 5")
     s, _ = main("show last week")
     assert "01:00" in s
     assert "05:00" in s
Exemple #20
0
 def test_came_weekday_capital_letter(self):
     s, _ = main("Monday came 9")
     assert "09:00" in s
Exemple #21
0
 def test_came_yesterday_monday_reorder(self):
     s, _ = main("yesterday came 9")
     assert "09:00" in s
Exemple #22
0
 def test_came_yesterday_sunday(self, mockdate_monday):
     s, _ = main("came 9 yesterday")
     assert "09:00" not in s
Exemple #23
0
 def test_came_yesterday_monday(self):
     s, _ = main("came 9 yesterday")
     assert "09:00" in s
Exemple #24
0
 def test_overwrite_came(self):
     main("came 9")
     s, _ = main("came 10")
     assert "9:00" not in s
     assert "10:00" in s
Exemple #25
0
 def test_trailing_arguments_error_2(self):
     s, _ = main("came 9 18")
     assert "Error" in s
     assert "18" in s
Exemple #26
0
 def test_came_9_t_17(self):
     main("came 9")
     main("17")
Exemple #27
0
 def test_came_followed_by_nothing_shall_not_crash(self):
     out, _ = main("came")
     assert 'Expected time after "came"' in out
Exemple #28
0
 def test_report_once(self):
     s, _ = main("came 9")
     assert "09:00" in s
Exemple #29
0
 def test_no_crash_anymore(self, custom_log_path):
     custom_log_path(
         Path(os.path.realpath(__file__)).parent / "_fixtures" / "crash.yaml"
     )
     main()
Exemple #30
0
 def test_report_twice(self):
     main("came 9")
     s, _ = main("left 18")
     assert "09:00" in s
     assert "18:00" in s