Esempio n. 1
0
def main(stdin):
    parser = TimeWarriorParser(stdin)
    tw_config = parser.get_config()
    tw_intervals = parser.get_intervals()

    root = store_intervals_in_tree(tw_intervals)
    print_report(root)
Esempio n. 2
0
def test_parser_with_default_settings(plain_export):
    parser = TimeWarriorParser(plain_export.open('r'))

    config = parser.get_config()

    assert (config.get_boolean('verbose', True) is False)
    assert (config.get_boolean('debug', True) is False)
    assert (config.get_boolean('confirmation', True) is False)
Esempio n. 3
0
def test_parser_should_parse_interval_without_tags(export_with_interval_without_tags):
    parser = TimeWarriorParser(export_with_interval_without_tags.open('r'))

    intervals = parser.get_intervals()
    expected = [
        TimeWarriorInterval(1, '20160405T160000Z', '20160405T161000Z', [], None),
    ]
    assert (intervals == expected)
Esempio n. 4
0
def test_parser_should_parse_open_interval(export_with_open_interval):
    parser = TimeWarriorParser(export_with_open_interval.open('r'))

    intervals = parser.get_intervals()
    expected = [
        TimeWarriorInterval(1, '20160405T160000Z', None, ['This is a multi-word tag', 'ProjectA', 'tag123'], None),
    ]
    assert (intervals == expected)
Esempio n. 5
0
def test_parser_with_empty_settings(plain_export_with_empty_entries):
    parser = TimeWarriorParser(plain_export_with_empty_entries.open('r'))

    config = parser.get_config()

    assert (config.get_value('name1', "default-name1") != "default-name1")
    assert (config.get_value('name2', "default-name2") != "default-name2")
    assert (config.get_value('name3', "default-name3") != "default-name3")
Esempio n. 6
0
def load_testdata(filename):
    '''This function allows testing functions with a static data set instead of the real data from timewarrior.
    To create a static data set from your real data, comment main(sys.stdin) and uncomment print(stdin.read()) in if __name__ == "__main__", and then run timew catreport > static-data
    '''
    with open(filename, "r") as f:
        parser = TimeWarriorParser(f)
    tw_config = parser.get_config()
    tw_intervals = parser.get_intervals()
    return tw_config.get_dict(), tw_intervals
Esempio n. 7
0
    def test_happy_path(self):
        with mock.patch("builtins.open", mock.mock_open(read_data=INI_FILE)):
            config = BillWarriorConfig()

        timewparser = TimeWarriorParser(StringIO(TIMEW_REPORT))

        invoice = Invoice(timewparser.get_intervals(), config)

        self.assertEqual(str(invoice), EXPECTED_OUTPUT)
Esempio n. 8
0
def test_parser_should_parse_intervals(export_with_intervals):
    parser = TimeWarriorParser(export_with_intervals.open('r'))

    intervals = parser.get_intervals()
    expected = [
        TimeWarriorInterval(
            '20160405T160000Z', '20160405T161000Z',
            ['This is a multi-word tag', 'ProjectA', 'tag123']),
        TimeWarriorInterval(
            '20160405T161000Z', '20160405T162000Z',
            ['This is a multi-word tag', 'ProjectA', 'tag123']),
        TimeWarriorInterval(
            '20160405T162000Z', '20160405T163000Z',
            ['This is a multi-word tag', 'ProjectA', 'tag123']),
    ]
    assert (intervals == expected)
Esempio n. 9
0
def test_parser_should_detect_confirmation_setting(export_with_confirmation):
    parser = TimeWarriorParser(export_with_confirmation.open('r'))

    config = parser.get_config()

    assert (config.get_boolean('confirmation', False) is True)
Esempio n. 10
0
def test_parser_should_detect_debug_setting(export_with_debug):
    parser = TimeWarriorParser(export_with_debug.open('r'))

    config = parser.get_config()

    assert (config.get_boolean('debug', False) is True)
Esempio n. 11
0
def test_parser_should_detect_verbose_setting(export_with_verbose):
    parser = TimeWarriorParser(export_with_verbose.open('r'))

    config = parser.get_config()

    assert (config.get_boolean('verbose', False) is True)
Esempio n. 12
0
class Day:
    def __init__(self):
        self.data = {}

    def addInterval(self, date, interval):
        if date not in self.data.keys():
            self.data[date] = []
        self.data[date].append(interval)

    def truncateData(self):
        for key, value in self.data.items():
            pass


parser = TimeWarriorParser(sys.stdin)
conf = parser.get_config()
reportStart = dateutil.parser.parse(
    conf.get_value('temp.report.start',
                   datetime.now())).astimezone(dateutil.tz.tzlocal())
reportEnd = dateutil.parser.parse(
    conf.get_value('temp.report.end',
                   datetime.now())).astimezone(dateutil.tz.tzlocal())

## Adding Holidays and Weekends
currentDate = reportStart
report = Day()

for i in parser.get_intervals():
    report.addInterval(
        i.get_start().date(),