Example #1
0
 def test_add_booking_unknown2(self):
     with pytest.raises(PublicError, match='Unknown room'):
         add_booking(
             (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
             'неизвестная',
             3,
             '12:00',
             '12:30',
             '*****@*****.**',
         )
Example #2
0
 def test_add_duplicate(self):
     add_booking(
         (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
         'гэб',
         3,
         '12:00',
         '12:30',
         '*****@*****.**',
     )
     with pytest.raises(PublicError,
                        match='This room is not available at that time'):
         add_booking(
             (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
             'гэб',
             3,
             '12:00',
             '12:30',
             '*****@*****.**',
         )
Example #3
0
    def test_delete_booking(self):
        event = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '12:00',
            '12:30',
            '*****@*****.**',
        )

        delete_booking(event.uuid, '*****@*****.**')
Example #4
0
    def test_add_booking_back_to_back(self):
        event1 = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '09:00',
            '09:30',
            '*****@*****.**',
        )
        event2 = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '09:30',
            '10:00',
            '*****@*****.**',
        )

        assert event1.title == 'Бронь ГЭБ, 3 человек, [email protected]'
        assert event2.title == 'Бронь ГЭБ, 3 человек, [email protected]'
Example #5
0
    def test_add_booking_midnight(self):
        event = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '23:00',
            '24:00',
            '*****@*****.**',
        )

        assert event.title == 'Бронь ГЭБ, 3 человек, [email protected]'
Example #6
0
    def test_delete_booking_prefix_access(self):
        event = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '12:00',
            '12:30',
            '*****@*****.**',
        )

        with pytest.raises(PublicError, match='Access denied'):
            delete_booking(event.uuid, '*****@*****.**')
Example #7
0
    def test_add_booking(self):
        event = add_booking(
            (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
            'гэб',
            3,
            '12:00',
            '12:30',
            '*****@*****.**',
        )

        assert event.title == 'Бронь ГЭБ, 3 человек, [email protected]'
        assert event.location == 'ГЭБ'
        assert event.event_type == 'private'
        assert event.start.hour == 12  # correct timezone
        assert event.creator == '*****@*****.**'
Example #8
0
 def test_returns_all(self):
     d = datetime.now(TZ) + timedelta(days=1)
     add_booking(d.strftime('%Y-%m-%d'), 'гэб', 3, '12:00', '12:30',
                 '*****@*****.**')
     add_booking(d.strftime('%Y-%m-%d'), 'гэб', 3, '13:00', '13:30',
                 '*****@*****.**')
     add_booking(
         (d + timedelta(days=1)).strftime('%Y-%m-%d'),
         'гэб',
         3,
         '13:00',
         '13:30',
         '*****@*****.**',
     )
     result = day_bookings(d)
     assert len(result) == 2
Example #9
0
def test_google_export(test_google_calendar_id):
    event = add_booking(
        (datetime.now(TZ) + timedelta(days=1)).strftime('%Y-%m-%d'),
        'гэб',
        3,
        '12:00',
        '12:30',
        '*****@*****.**',
    )

    google_calendar = GoogleCalendar.objects.create(
        calendar_id=test_google_calendar_id,
        public_only=False,
    )
    google_calendar.export_event(event)

    google_event = google_calendar.google_events.get(event=event)
    google_data = google_event.load_google_data()
    attendees = google_data['attendees']
    assert len(attendees) == 1
    assert attendees[0]['email'] == '*****@*****.**'
    assert google_data['location'] == 'Кочерга, комната ГЭБ'
    assert event.location == 'ГЭБ'
Example #10
0
 def test_no_params(self):
     with pytest.raises(TypeError):
         add_booking()  # type: ignore
Example #11
0
 def test_too_far_date(self):
     with pytest.raises(PublicError, match='too far'):
         add_booking('2025-01-01', 'гэб', 3, '12:00', '12:30',
                     '*****@*****.**')
Example #12
0
 def test_past_date(self):
     with pytest.raises(PublicError, match='The past is already gone'):
         add_booking('2017-01-01', 'гэб', 3, '12:00', '12:30',
                     '*****@*****.**')
Example #13
0
 def test_validate_room(self):
     with pytest.raises(PublicError, match='Unknown room'):
         add_booking('2017-01-01', 'blah', 3, '12:00', '12:30',
                     '*****@*****.**')
Example #14
0
 def test_validate_zero_people(self):
     with pytest.raises(PublicError, match='Zero people walk into a bar'):
         add_booking('2017-01-01', 'гэб', 0, '12:00', '12:30',
                     '*****@*****.**')
Example #15
0
 def test_validate_people_number(self):
     with pytest.raises(PublicError, match='Invalid number of people'):
         add_booking('2017-01-01', 'гэб', -5, '12:00', '12:30',
                     '*****@*****.**')