Beispiel #1
0
    def test_equality(self):
        event = fixture_vera_event()
        event2 = fixture_vera_event()
        event3 = fixture_vera_event_mock()
        event3.url = 'www.googlge'

        assert_that(event, equal_to(event2))
        assert_that(event2, equal_to(event))
        assert_that(event2, is_not(equal_to(event3)))
        assert_that(event, is_not(equal_to(event3)))
 def test_mapping_to_entity(self):
     entity = EventEntityTransformer.to_entity(fixture_vera_event())
     assert_that(entity['url'], fixture_vera_event().url)
     assert_that(entity['venue_id'], fixture_vera_event().venue.venue_id)
     assert_that(entity['image_url'], fixture_vera_event().image_url)
     assert_that(entity['source'], fixture_vera_event().source)
     assert_that(entity['when'], fixture_vera_event().when)
     assert_that(entity['description'], fixture_vera_event().description)
     assert_that(entity['title'], fixture_vera_event().title)
Beispiel #3
0
    def test_when_too_old(self):
        event = fixture_vera_event()
        event.when = datetime.now(pytz.timezone('Europe/Amsterdam')) - timedelta(days=1)
        assert_that(event.is_valid(), equal_to(False))

        event.when = datetime.now(pytz.timezone('Europe/Amsterdam')) - timedelta(minutes=1)
        assert_that(event.is_valid(), equal_to(False))

        event.when = datetime.now(pytz.timezone('Europe/Amsterdam')) + timedelta(minutes=1)
        assert_that(event.is_valid(), equal_to(True))
Beispiel #4
0
 def test_as_xml(self):
     event = fixture_vera_event()
     rss_item = Transformer().item_to_rss(event)
     assert_that(rss_item.title, equal_to('Vera Event titel'))
     assert_that(rss_item.author, equal_to('vera'))
     assert_that(rss_item.guid, equal_to('http://dummy-vera-event'))
     assert_that(rss_item.link, equal_to('http://dummy-vera-event'))
     description = rss_item.description
     assert_that(description, matches_regexp('<p>Omschrijving</p>'))
     assert_that(description, matches_regexp(
         'Where: <a href="http://venue-url-vera-groningen">VERA-Groningen .Groningen, NL.</a></p>'))
     assert_that(description, matches_regexp('<p>When: \\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d -'))
Beispiel #5
0
 def test_when(self):
     event = fixture_vera_event()
     event.when = datetime.min
     assert_that(event.is_valid(), equal_to(False))
Beispiel #6
0
 def test_description(self):
     event = fixture_vera_event()
     event.description = None
     assert_that(event.is_valid(), equal_to(False))
     event.description = ''
     assert_that(event.is_valid(), equal_to(False))
Beispiel #7
0
 def test_url(self):
     event = fixture_vera_event()
     event.url = None
     assert_that(event.is_valid(), equal_to(False))
     event.url = ''
     assert_that(event.is_valid(), equal_to(False))
Beispiel #8
0
 def test_valid(self):
     assert_that(fixture_vera_event().is_valid(), equal_to(True))