def test_returns_correct_date_when_end_date_during_weekend_for_other( self, other_scan_event_on_friday): assert other_scan_event_on_friday['status_scan'] not in set( PLUS_1_DAY_SCANS + PLUS_2_DAYS_SCANS + SAME_DAY_SCANS) est_delivery_date = get_est_delivery_date_from_event( other_scan_event_on_friday) assert est_delivery_date == datetime.datetime(2018, 4, 9, 0, 0)
def get_tracking_events(request): label_id = request.GET.get('label_id') if not label_id: data = {'success': False, 'message': 'A tracking number is required.'} return JsonResponse(data, status=400) try: events = domain.get_tracking_events(label_id) except Exception as exc: data = {'success': False, 'message': str(exc)} return JsonResponse(data, status=400) est_delivery_date = get_est_delivery_date_from_event(events[-1]) return render( request, 'tracker/events_panel.html', { 'success': True, 'label_id': label_id, 'events': events, 'est_delivery_day': est_delivery_date.strftime('%d'), 'est_delivery_day_str': est_delivery_date.strftime('%A'), 'est_delivery_month': est_delivery_date.strftime('%B %Y'), 'recipient_data': get_recipient_data(events), })
def test_returns_correct_date_when_end_date_during_weekend_for_rtd( self, rtd_scan_event_on_friday): est_delivery_date = get_est_delivery_date_from_event( rtd_scan_event_on_friday) assert est_delivery_date == datetime.datetime(2018, 4, 9, 0, 0)
def test_returns_correct_date_when_end_date_during_bank_holiday_for_r02( self, r02_scan_event_day_before_bank_holiday): est_delivery_date = get_est_delivery_date_from_event( r02_scan_event_day_before_bank_holiday) assert est_delivery_date == datetime.datetime(2018, 4, 3, 0, 0)
def test_returns_correct_date_when_end_date_during_weekend_and_before_bank_holiday( # noqa self, ds1_scan_event_on_friday): ds1_scan_event_on_friday['date'] = 'October 26, 2018' est_delivery_date = get_est_delivery_date_from_event( ds1_scan_event_on_friday) assert est_delivery_date == datetime.datetime(2018, 10, 30, 0, 0)
def test_returns_correct_date(self, hdn_scan_event): est_delivery_date = get_est_delivery_date_from_event(hdn_scan_event) assert est_delivery_date.strftime( '%B %d, %Y') == hdn_scan_event['date']