Esempio n. 1
0
    def test_create_overlapping_banners(self, current_banner, date):
        # Banner overlapping on end
        with pytest.raises(ValidationValueError) as e:
            ScheduledBannerFactory(
                start_date=date + timedelta(days=3),
                end_date=date + timedelta(days=6)
            )
        assert e.value.message == 'Banners dates cannot be overlapping.'

        # Banner overlapping on start
        with pytest.raises(ValidationValueError) as e:
            ScheduledBannerFactory(
                start_date=date - timedelta(days=1),
                end_date=date + timedelta(days=1)
            )
        assert e.value.message == 'Banners dates cannot be overlapping.'

        # Banner overlapping in middle
        with pytest.raises(ValidationValueError) as e:
            ScheduledBannerFactory(
                start_date=date + timedelta(days=1),
                end_date=date + timedelta(days=2)
            )
        assert e.value.message == 'Banners dates cannot be overlapping.'

        # Banner with invalid start/end dates
        with pytest.raises(ValidationValueError) as e:
            ScheduledBannerFactory(
                start_date=date + timedelta(days=8),
                end_date=date + timedelta(days=7)
            )
        assert e.value.message == 'Start date must be before end date.'

        # Banner ends right before next starts
        ScheduledBannerFactory(
            start_date=date - timedelta(days=3),
            end_date=date - timedelta(days=1)
        )

        # Banner begins right after previous ends
        ScheduledBannerFactory(
            start_date=date + timedelta(days=5)
        )
Esempio n. 2
0
 def yesterday_banner(self, date):
     return ScheduledBannerFactory(
         start_date=date - timedelta(days=1)
     )
Esempio n. 3
0
 def tomorrow_banner(self, date):
     return ScheduledBannerFactory(
         start_date=date + timedelta(days=1)
     )
Esempio n. 4
0
 def banner(self):
     return ScheduledBannerFactory()
Esempio n. 5
0
def today_banner():
    return ScheduledBannerFactory()
Esempio n. 6
0
 def current_banner(self, date):
     return ScheduledBannerFactory(
         start_date=date,
         end_date=date + timedelta(days=4)
     )