def test_finalize_poll(self):
     Polls.finalize(self.new_poll.id, self.new_option.id,
                    self.new_user.username)
     self.assertEqual(
         EventPolls.objects.filter(
             id=self.new_poll.id).values("is_finalized")[0]['is_finalized'],
         True)
Example #2
0
    def test_create_poll(self):
        Polls.create_poll(self.request_body)

        self.assertEqual(EventPolls.objects.filter(creator__username= '******').values_list('title', flat= True)[0],
                         'test title')

        self.assertEqual(Options.objects.filter(event_poll__creator__username= '******').values_list('label', flat= True)[0],
                         'test label')
    def test_reopen_poll(self):
        Polls.finalize(self.new_poll.id, self.new_option.id,
                       self.new_user.username)
        fields = {}
        fields['pollId'] = self.new_poll.id
        fields['notificationMessage'] = "new notification message"
        Polls.reopen_poll(fields)
        print(
            EventPolls.objects.filter(
                id=self.new_poll.id).values("is_finalized")[0]['is_finalized'])

        self.assertEqual(
            EventPolls.objects.filter(
                id=self.new_poll.id).values("is_finalized")[0]['is_finalized'],
            False)
    def post(self, request):
        request_body = get_request_body(request)
        involved_polls = Polls.get_involved_polls(request_body['username'])

        return JsonResponse(involved_polls,
                            safe=False,
                            content_type="application/json")
Example #5
0
    def post(self, request):
        request_body = get_request_body(request)
        result = Polls.create_poll(request_body)

        return JsonResponse(result,
                            safe=False,
                            content_type="application/json")
Example #6
0
 def post(self, request):
     request_body = get_request_body(request)
     result = Polls.checkCollision(request_body['username'],
                                   request_body['timeToCheck']['startDate'],
                                   request_body['timeToCheck']['endDate'])
     return JsonResponse({"data": result},
                         safe=False,
                         content_type="application/json")
 def get(self, request):
     request_parameters = get_request_parameters(request)
     poll = Polls.get_poll(request_parameters['id'])
     return JsonResponse(poll, content_type="application/json")
    def post(self, request):
        request_body = get_request_body(request)
        result = Polls.reopen_poll(request_body)

        return JsonResponse(result, content_type="application/json")
 def test_get_involved_polls(self):
     polls = Polls.get_involved_polls('test')
     self.assertEqual(polls[0]['event_poll__title'], 'test')
 def test_get_created_polls(self):
     polls = Polls.get_created_polls('test')
     self.assertEqual(polls[0]['title'], 'test')
 def test_get_poll(self):
     poll = Polls.get_poll(self.new_poll.id)
     self.assertEqual(poll['title'], 'test')
     self.assertEqual(poll['options'][0]['label'], 'test')
Example #12
0
    def post(self, request):
        request_body = get_request_body(request)
        result = Polls.finalize(request_body['pollId'], request_body['finalizeOptionId'], request_body['username'])

        return JsonResponse(result, content_type="application/json")