def test_past_disruption_2_periods(): ''' application_period 2014-02-10 2014-03-10 application_period 2014-03-12 2014-03-15 current date 2014-03-16 disruption.status past ''' disruption = models.Disruption() disruption.start_publication_date = datetime(2014, 2, 10, 13, 5, 10) disruption.end_publication_date = datetime(2014, 3, 16, 13, 5, 10) impact = models.Impact() application_period = models.ApplicationPeriods() application_period.start_date = datetime(2014, 2, 10, 13, 5, 10) application_period.end_date = datetime(2014, 3, 10, 13, 5, 10) impact.application_periods.append(application_period) application_period = models.ApplicationPeriods() application_period.start_date = datetime(2014, 3, 12, 13, 5, 10) application_period.end_date = datetime(2014, 3, 15, 13, 5, 10) impact.application_periods.append(application_period) disruption.impacts.append(impact) impact.disruption = disruption with app.app_context(): g.current_time = datetime(2014, 3, 16, 13, 5, 10) class_time = fields.ComputeDisruptionStatus(Obj()) eq_(class_time.output(None, impact), 'past')
def test_activate_status_disruption(): disruption = models.Disruption() disruption.start_publication_date = datetime(2014, 2, 10, 13, 5, 10) disruption.end_publication_date = datetime(2014, 3, 10, 13, 5, 10) impact = models.Impact() application_period = models.ApplicationPeriods() application_period.start_date = datetime(2014, 2, 10, 13, 5, 10) application_period.end_date = datetime(2014, 3, 10, 13, 5, 10) impact.application_periods.append(application_period) disruption.impacts.append(impact) impact.disruption = disruption with app.app_context(): g.current_time = datetime(2014, 2, 11, 13, 5, 10) class_time = fields.ComputeDisruptionStatus(Obj()) eq_(class_time.output(None, impact), 'active')