Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the version of timew-report #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
timew-report = "<1.3"
timew-report = ">=1.4"

[dev-packages]
pytest = "*"
Expand Down
30 changes: 27 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions billwarrior/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def __init__(self, intervals, config):

for category in sorted(sorted_intervals.keys(), key=config.text_for):
intervals = sorted_intervals[category]
days = set([interval.get_date().date() for interval in intervals])
days = set([interval.get_start_date() for interval in intervals])
intervals_by_day = {
day: [i for i in intervals if i.get_date().date() == day]
day: [i for i in intervals if i.get_start_date() == day]
for day in days
}

Expand Down
30 changes: 15 additions & 15 deletions tests/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def test_creates_different_categories_from_interval_tags_and_mapping(self):
items = invoice.items()

expected_a, expected_b = (
ItemCategory("Consulting & Research", {a.get_date().date(): [a]}, 0.0),
ItemCategory("Travel", {b.get_date().date(): [b]}, 0.0),
ItemCategory("Consulting & Research", {a.get_start_date(): [a]}, 0.0),
ItemCategory("Travel", {b.get_start_date(): [b]}, 0.0),
)

self.assertEqual(len(items), 2)
Expand All @@ -91,7 +91,7 @@ def test_groups_intervals_of_same_category(self):

expected = ItemCategory(
"Consulting & Research",
{same_day.date(): [a, b], c.get_date().date(): [c]},
{same_day.date(): [a, b], c.get_start_date(): [c]},
0.0,
)

Expand Down Expand Up @@ -155,12 +155,12 @@ def test_sets_unit_price_for_item_category(self):
expected_a, expected_b = (
ItemCategory(
"Consulting & Research",
{a.get_date().date(): [a]},
{a.get_start_date(): [a]},
billw_config.rate_for(category_a),
),
ItemCategory(
"Software Development",
{b.get_date().date(): [b]},
{b.get_start_date(): [b]},
billw_config.rate_for(category_b),
),
)
Expand Down Expand Up @@ -189,12 +189,12 @@ def test_alpha_orders_categories(self):
expected_a, expected_b = (
ItemCategory(
"Consulting & Research",
{a.get_date().date(): [a]},
{a.get_start_date(): [a]},
billw_config.rate_for(category_a),
),
ItemCategory(
"Software Development",
{b.get_date().date(): [b]},
{b.get_start_date(): [b]},
billw_config.rate_for(category_b),
),
)
Expand All @@ -219,12 +219,12 @@ def test_prints_invoice_categories_and_items(self):
expected_a, expected_b = (
ItemCategory(
"Consulting & Research",
{a.get_date().date(): [a]},
{a.get_start_date(): [a]},
billw_config.rate_for(category_a),
),
ItemCategory(
"Software Development",
{b.get_date().date(): [b]},
{b.get_start_date(): [b]},
billw_config.rate_for(category_b),
),
)
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_line_items_should_be_populated_with_entries_per_day(self):
[tests.give_interval(a_day + timedelta(days=2))],
[tests.give_interval(a_day + timedelta(days=3))],
]
intervals_by_day = {entry[0].get_date().date(): entry for entry in entries}
intervals_by_day = {entry[0].get_start_date(): entry for entry in entries}

category = ItemCategory("arbitray category", intervals_by_day, 0.0)

Expand All @@ -265,11 +265,11 @@ def test_line_items_should_be_sorted_by_date(self):
[tests.give_interval()],
[tests.give_interval()],
]
dates = [entry[0].get_date().date() for entry in entries]
dates = [entry[0].get_start_date() for entry in entries]

category = ItemCategory("arbitray category", dict(zip(dates, entries)), 0.0)

sorted_date_list = sorted([entry[0].get_date().date() for entry in entries])
sorted_date_list = sorted([entry[0].get_start_date() for entry in entries])
self.assertListEqual(
[
datetime.strptime(line_item.date, "%B %d, %Y").date()
Expand All @@ -280,7 +280,7 @@ def test_line_items_should_be_sorted_by_date(self):

def test_str_should_display_header_line_items_and_subtotal_as_latex_output(self):
a, b = tests.give_interval(), tests.give_interval()
entries = {a.get_date().date(): [a], b.get_date().date(): [b]}
entries = {a.get_start_date(): [a], b.get_start_date(): [b]}

category = ItemCategory("arbitrary category", entries, 0.0)

Expand All @@ -289,8 +289,8 @@ def test_str_should_display_header_line_items_and_subtotal_as_latex_output(self)
"\\feetype{%s}\n" % category.header,
"".join(
[
"%s\n" % LineItem(i.get_date(), i.get_duration(), 0.0)
for i in sorted([a, b], key=lambda x: x.get_date())
"%s\n" % LineItem(i.get_start_date(), i.get_duration(), 0.0)
for i in sorted([a, b], key=lambda x: x.get_start_date())
]
),
"\\subtotal\n",
Expand Down
2 changes: 1 addition & 1 deletion tests/testsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def give_interval(day=None, tags=[]):

end = start + timedelta(0, randint(60 * 5, 60 * 60 * 2)) # up to 2h

return TimeWarriorInterval(start.strftime(DT_FORMAT), end.strftime(DT_FORMAT), tags)
return TimeWarriorInterval(start.strftime(DT_FORMAT), end.strftime(DT_FORMAT), tags, None)