def test_EventsByBusStopv2(self): '''This method test two thing, the posibility to report an event and asking the events for the specific busStop''' busStopCode = 'PA459' eventCode = 'evn00001' # submitting some events to the server request = self.factory.get('/android/reportEventBusStop/v2/') request.user = AnonymousUser() request0 = self.factory.get('/android/requestEventsForBusStop/v2/') request0.user = AnonymousUser() reponseView = RegisterEventBusStop() # make a report reponseView.get( request, self.userId, busStopCode, eventCode, 'confirm') # report one event, and confirm it response0View = EventsByBusStop() response0 = response0View.get(request0, busStopCode) response0 = json.loads(response0.content) self.assertEqual(response0['codeBusStop'], busStopCode) self.assertEqual(response0['events'][0]['eventDecline'], 0) self.assertEqual(response0['events'][0]['eventConfirm'], 1) self.assertEqual(response0['events'][0]['eventcode'], eventCode) # do event +1 to the event reponseView.get( request, self.userId, busStopCode, eventCode, 'confirm') response0 = response0View.get(request0, busStopCode) response0 = json.loads(response0.content) self.assertEqual(response0['codeBusStop'], busStopCode) self.assertEqual(response0['events'][0]['eventDecline'], 0) self.assertEqual(response0['events'][0]['eventConfirm'], 2) self.assertEqual(response0['events'][0]['eventcode'], eventCode) # do event -1 to the event reponseView.get( request, self.userId, busStopCode, eventCode, 'decline') response0 = response0View.get(request0, busStopCode) response0 = json.loads(response0.content) self.assertEqual(response0['codeBusStop'], busStopCode) self.assertEqual(response0['events'][0]['eventDecline'], 1) self.assertEqual(response0['events'][0]['eventConfirm'], 2) self.assertEqual(response0['events'][0]['eventcode'], eventCode) # change manualy the timeStamp to simulate an event that has expired busStop = BusStop.objects.get(code=busStopCode) event = Event.objects.get(id=eventCode) anEvent = EventForBusStop.objects.get(busStop=busStop, event=event) anEvent.timeStamp = anEvent.timeCreation - \ timezone.timedelta(minutes=event.lifespam) anEvent.save() # ask for ecents and the answere should be none response0 = response0View.get(request0, busStopCode) response0 = json.loads(response0.content) self.assertEqual(len(response0['events']), 0)
url( r'^reportEventBus/(?P<pUserId>[0-9a-z-]+)/(?P<pBusService>[\w,0-9]*)/(?P<pBusPlate>[\w,0-9,-]*)/(?P<pEventID>.*)/(?P<pLatitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pLongitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pConfirmDecline>.*)$', RegisterEventBus.as_view()), url( r'^reportEventBus/v2/(?P<pUserId>[0-9a-z-]+)/(?P<pUuid>[0-9a-z-]+)/(?P<pBusService>[\w,0-9]*)/(?P<pEventID>.*)/(?P<pLatitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pLongitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pConfirmDecline>.*)$', RegisterEventBusV2.as_view()), # reportEventBus without location url( r'^reportEventBus/(?P<pUserId>[0-9a-z-]+)/(?P<pBusService>[\w,0-9]*)/(?P<pBusPlate>[\w,0-9,-]*)/(?P<pEventID>.*)/(?P<pConfirmDecline>.*)$', RegisterEventBus.as_view()), url( r'^reportEventBus/v2/(?P<pUserId>[0-9a-z-]+)/(?P<pUuid>[0-9a-z-]+)/(?P<pBusService>[\w,0-9]*)/(?P<pEventID>.*)/(?P<pConfirmDecline>.*)$', RegisterEventBusV2.as_view()), url( r'^reportEventBusStop/(?P<pUserId>[0-9a-z-]+)/(?P<pBusStopCode>[\w,0-9]*)/(?P<pEventID>.*)/(?P<pLatitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pLongitud>[\-+]?[0-9]*\.?[0-9]*)/(?P<pConfirmDecline>.*)$', RegisterEventBusStop.as_view()), url( r'^reportEventBusStop/(?P<pUserId>[0-9a-z-]+)/(?P<pBusStopCode>[\w,0-9]*)/(?P<pEventID>.*)/(?P<pConfirmDecline>.*)$', RegisterEventBusStop.as_view()), # List of events that depend of parameter pWhich={stopstop,stopbus, busbus} url(r'^requestEventsToNotified/(?P<pWhich>[\w,0-9]*)$', RequestEventsToNotified.as_view()), # List of bus events url( r'^requestEventsForBus/(?P<pRegistrationPlate>[\w,0-9,-]{6,8})/(?P<pBusService>[\w,0-9]*)$', EventsByBus.as_view()), url(r'^requestEventsForBus/v2/(?P<pUuid>[0-9a-z-]+)$', EventsByBusV2.as_view()), # List of bus stop events url( r'^requestEventsForBusStop/(?P<pBusStopCode>[\w,0-9]*)$',