Commit febf43b3 authored by Patrick Kimber's avatar Patrick Kimber

test 'get_calendars' and add month count #1181

parent 6e99fe9f
......@@ -156,11 +156,13 @@ class HtmlCalendar(object):
html = html + "</table>"
return html
def get_calendars(self):
def get_calendars(self, count=None):
result = []
if not count:
count = 12
bookings = self._get_bookings()
d = self.start_date
for i in range(0, 12):
for i in range(0, count):
html = self._generate_html(d, bookings)
# move to the 1st day of the next month
d = d + relativedelta(months=+1, day=1)
......
......@@ -45,6 +45,25 @@ def test_get_calendars():
c.get_calendars()
@pytest.mark.django_db
def test_get_calendars_html():
today = date.today()
BookingFactory(
start_date=date(today.year, today.month, 3),
end_date=date(today.year, today.month, 5),
)
c = HtmlCalendar()
result = c.get_calendars(count=1)
assert type(result) is list
assert len(result) == 1
html = result[0]
assert "<td>02</td>" in html
assert "<td class='afternoon'>03</td>" in html
assert "<td class='booked'>04</td>" in html
assert "<td class='morning'>05</td>" in html
assert "<td>06</td>" in html
@pytest.mark.django_db
def test_booking_count():
c = BookingCount()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment