Esempio n. 1
0
 def setUp(self):
     self.page = EventPage(title='Super fun event',
                           start_dt=datetime.now(timezone('UTC')),
                           venue_city='Boston',
                           venue_state='MA')
     save_new_page(self.page)
     self.migration = import_module(
         'v1.migrations.0155_add_venue_coords_to_existing_events')
Esempio n. 2
0
 def test_past_event_with_video_includes_video_js(self):
     page = EventPage(
         title='Past event with youtube_url',
         start_dt=datetime.datetime(2011, 1, 1, tzinfo=pytz.UTC),
         end_dt=datetime.datetime(2011, 1, 2, tzinfo=pytz.UTC),
         youtube_url='https://www.youtube.com/embed/Aa1Bb2Cc3Dc4')
     save_new_page(page)
     self.assertEqual('past', page.event_state)
     self.assertIn('video-player.js', page.page_js)
 def test_past_event_with_video_includes_video_js(self):
     page = EventPage(title='Past event with archive_video_id',
                      start_dt=datetime.datetime(2011,
                                                 1,
                                                 1,
                                                 tzinfo=pytz.UTC),
                      end_dt=datetime.datetime(2011, 1, 2, tzinfo=pytz.UTC),
                      archive_video_id='Aa1Bb2Cc3Dc')
     save_new_page(page)
     self.assertEqual('past', page.event_state)
     self.assertIn('video-player.js', page.page_js)
    def test_video_js_not_included_on_event_when_not_needed(self):
        page = EventPage(title='Future event with no end date',
                         start_dt=datetime.datetime(2011,
                                                    1,
                                                    4,
                                                    tzinfo=pytz.UTC))
        save_new_page(page)
        self.assertEqual('future', page.event_state)
        self.assertNotIn('video-player.js', page.page_js)

        page = EventPage(title='Future event with end date',
                         start_dt=datetime.datetime(2011,
                                                    1,
                                                    4,
                                                    tzinfo=pytz.UTC),
                         end_dt=datetime.datetime(2011, 1, 5, tzinfo=pytz.UTC))
        save_new_page(page)
        self.assertEqual('future', page.event_state)
        self.assertNotIn('video-player.js', page.page_js)

        page = EventPage(title='Present event with no live_stream_date',
                         start_dt=datetime.datetime(2011,
                                                    1,
                                                    2,
                                                    tzinfo=pytz.UTC),
                         end_dt=datetime.datetime(2011, 1, 4, tzinfo=pytz.UTC))
        save_new_page(page)
        self.assertEqual('present', page.event_state)
        self.assertNotIn('video-player.js', page.page_js)

        page = EventPage(title='Past event with no archive_video_id',
                         start_dt=datetime.datetime(2011,
                                                    1,
                                                    1,
                                                    tzinfo=pytz.UTC),
                         end_dt=datetime.datetime(2011, 1, 2, tzinfo=pytz.UTC))
        save_new_page(page)
        self.assertEqual('past', page.event_state)
        self.assertNotIn('video-player.js', page.page_js)
 def test_present_event_with_livestream_includes_video_js(self):
     page = EventPage(title='Present event with live_stream_date',
                      start_dt=datetime.datetime(2011,
                                                 1,
                                                 2,
                                                 tzinfo=pytz.UTC),
                      end_dt=datetime.datetime(2011, 1, 4, tzinfo=pytz.UTC),
                      live_stream_date=datetime.datetime(2011,
                                                         1,
                                                         2,
                                                         tzinfo=pytz.UTC))
     save_new_page(page)
     self.assertEqual('present', page.event_state)
     self.assertIn('video-player.js', page.page_js)
Esempio n. 6
0
    def test_save_calls_get_venue_coords(self):
        api_url_re = re.compile('https://api.mapbox.com/geocoding/(.*)')
        data_json = {
            'features': [{
                'geometry': {
                    'coordinates': ['123.456', '321.654']
                }
            }]
        }
        responses.add(responses.GET, api_url_re, json=data_json)

        page = EventPage(title='Super fun event',
                         venue_city='Boston',
                         venue_state='MA')
        save_new_page(page)
        self.assertEqual(page.venue_coords, '123.456,321.654')
        self.assertIn('static/123.456,321.654', page.location_image_url())
Esempio n. 7
0
    def setUp(self):
        now = datetime.now(pytz.UTC)

        self.home_page = HomePage.objects.get(slug='cfgov')

        # Set up a root for updates
        self.updates_page = SublandingFilterablePage(
            title='Updates', slug='updates', live=True
        )
        self.home_page.add_child(instance=self.updates_page)
        self.updates_page.save_revision().publish()

        # Set up blogs
        self.blog_1 = BlogPage(
            title='Blog 1', slug='blog1', live=True
        )
        self.updates_page.add_child(instance=self.blog_1)
        self.blog_2 = BlogPage(
            title='Blog 2', slug='blog2', live=True
        )
        self.updates_page.add_child(instance=self.blog_2)
        self.blog_3 = BlogPage(
            title='Blog 3', slug='blog3', live=True
        )
        self.updates_page.add_child(instance=self.blog_3)

        # Set up some events
        self.event_1 = EventPage(
            title='Event 1',
            slug='event1',
            live=True,
            start_dt=now
        )
        self.updates_page.add_child(instance=self.event_1)
        self.event_2 = EventPage(
            title='Event 2',
            slug='event2',
            live=True,
            start_dt=now
        )
        self.updates_page.add_child(instance=self.event_2)
        self.event_3 = EventPage(
            title='Event 3',
            slug='event3',
            live=True,
            start_dt=now
        )
        self.updates_page.add_child(instance=self.event_3)

        # Set up some Newsroom posts
        self.news_1 = NewsroomPage(
            title='Newsroom 1', slug='news1', live=True
        )
        self.updates_page.add_child(instance=self.news_1)
        self.news_2 = NewsroomPage(
            title='Newsroom 2', slug='news2', live=True
        )
        self.updates_page.add_child(instance=self.news_2)
        self.news_3 = NewsroomPage(
            title='Newsroom 3', slug='news3', live=True
        )
        self.updates_page.add_child(instance=self.news_3)

        # Publish things in an order
        self.news_3.save_revision().publish()
        self.blog_2.save_revision().publish()
        self.event_2.save_revision().publish()
        self.blog_1.save_revision().publish()
        self.news_1.save_revision().publish()
        self.event_3.save_revision().publish()
        self.blog_3.save_revision().publish()
        self.event_1.save_revision().publish()
        self.news_2.save_revision().publish()

        # Set up some unpublished types
        self.unpublished_blog_1 = BlogPage(
            title='Unpublished blog 1', slug='unpublished_blog1', live=False
        )
        self.updates_page.add_child(instance=self.unpublished_blog_1)

        # Set up some events
        self.unpublished_event_1 = EventPage(
            title='Unpublished event 1',
            slug='unpublished_event1',
            live=False,
            start_dt=now
        )
        self.updates_page.add_child(instance=self.unpublished_event_1)

        # Set up some Newsroom posts
        self.unpublished_news_1 = NewsroomPage(
            title='Unpublished news 1', slug='unpublished_news1', live=False
        )
        self.updates_page.add_child(instance=self.unpublished_news_1)

        # Add an excluded update to exclude event_1
        self.home_page.excluded_updates.create(
            page=self.home_page, excluded_page=self.event_1
        )
        self.home_page.save_revision().publish()
Esempio n. 8
0
 def test_venue_coords_without_saving(self):
     page = EventPage(title='Party time')
     # Should get static image URL even if page hasn't been saved
     self.assertIn('static/-77.039628,38.898238', page.location_image_url())