Example #1
0
    def test_get_films_in_cinemas2(self):
        """ Tests situation when there are showtimes in the given country.
        """

        self.initialize()
        time_now = datetime.datetime.utcnow() + datetime.timedelta(0.1)

        self.warsaw = Town(country=self.poland,
                           name='Warsaw',
                           has_cinemas=True)
        self.warsaw.save()

        self.cinema_ww = Channel(type=TYPE_CINEMA,
                                 town=self.warsaw,
                                 address='Marszalkowska 2')
        self.cinema_ww.save()

        self.screen_ww1 = Screening(channel=self.cinema_ww,
                                    film=self.fc5,
                                    utc_time=time_now)
        self.screen_ww1.save()

        self.screen_ww2 = Screening(channel=self.cinema_ww,
                                    film=self.fc7,
                                    utc_time=time_now)
        self.screen_ww2.save()

        country_films = set([f.id for f in \
                get_films_in_cinemas_by_country(country_code='PL')])
        self.assertTrue(self.f7.id in country_films)
Example #2
0
    def get_theater(self, venue, city):
        from film20.showtimes.models import Channel, Town

        m = re.match("(.*)(\s+\d+)", venue)
        if m:
            venue = m.group(1)
        if (venue, city) in self.THEATER_MAP:
            venue, city = self.THEATER_MAP[(venue, city)]

        try:
            theater = Channel.objects.get(name=venue,
                                          town__name=city,
                                          town__country__code='US')
        except Channel.DoesNotExist:
            town = Town.objects.select_related('country').get(
                name=city, country__code='US')
            theater = Channel(name=venue,
                              town=town,
                              latitude=town.latitude,
                              longitude=town.longitude,
                              type=1)
            theater.save()
        self.festival.theaters.add(theater)
        return theater
Example #3
0
    def initialize(self):

        Film.objects.all().delete()

        self.poland = Country.objects.get(code='PL')

        self.init_films()
        self.usa = Country(name='USA', code='US')
        self.usa.save()

        self.new_york = Town(country=self.usa,
                             name='New York',
                             has_cinemas=True)
        self.new_york.save()

        self.cinema_ny = Channel(type=TYPE_CINEMA,
                                 town=self.new_york,
                                 address='Some Street 3')
        self.cinema_ny.save()

        self.hbo = Channel(type=TYPE_TV_CHANNEL, country=self.usa)
        self.hbo.save()

        self.tvp = Channel(type=TYPE_TV_CHANNEL, country=self.poland)
        self.tvp.save()

        time_now = datetime.datetime.utcnow() + datetime.timedelta(0.1)

        self.screen_ny1 = Screening(channel=self.cinema_ny,
                                    film=self.fc1,
                                    utc_time=time_now)
        self.screen_ny1.save()

        self.screen_ny2 = Screening(channel=self.cinema_ny,
                                    film=self.fc2,
                                    utc_time=time_now)
        self.screen_ny2.save()

        self.screen_ny3 = Screening(channel=self.cinema_ny,
                                    film=self.fc3,
                                    utc_time=time_now)
        self.screen_ny3.save()

        self.screen_ny4 = Screening(channel=self.cinema_ny,
                                    film=self.fc4,
                                    utc_time=time_now)
        self.screen_ny4.save()

        self.screen_ny5 = Screening(channel=self.cinema_ny,
                                    film=self.fc5,
                                    utc_time=time_now)
        self.screen_ny5.save()

        self.screen_hbo1 = Screening(channel=self.hbo,
                                     film=self.fc1,
                                     utc_time=time_now)
        self.screen_hbo1.save()

        self.screen_hbo2 = Screening(channel=self.hbo,
                                     film=self.fc2,
                                     utc_time=time_now)
        self.screen_hbo2.save()

        self.screen_hbo3 = Screening(channel=self.hbo,
                                     film=self.fc3,
                                     utc_time=time_now)
        self.screen_hbo3.save()

        self.screen_hbo4 = Screening(channel=self.hbo,
                                     film=self.fc4,
                                     utc_time=time_now)
        self.screen_hbo4.save()

        self.screen_hbo5 = Screening(channel=self.hbo,
                                     film=self.fc5,
                                     utc_time=time_now + datetime.timedelta(8))
        self.screen_hbo5.save()