class CalculatorTest(unittest.TestCase): def setUp(self): self.event = Event(pk=1) self.calculator = Calculator(self.event) def testAmount(self): self.assertEqual(self.calculator.amount(), 100)
def get(self, request): participant = Participant.objects.get( Q(email=request.user.username) | Q(email=request.user.email) ) event = participant.event.select_related()[0] calculator = Calculator(event) return Response( status.HTTP_200_OK, { "event" : event, "participant" : participant, "amount" : calculator.amount(), "participantAmount": calculator.participantAmount(participant) } )