Exemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        if "price" not in request.POST:
            return HttpResponseBadRequest(
                json.dumps({"message": "missing parameter"}))

        try:
            price = int(request.POST.get("price"))
        except ValueError:
            return HttpResponseBadRequest(
                json.dumps({"message": "price must be int"}))

        SeveralCosts.set_living_cost_mark(price)
        return HttpResponse(json.dumps({"message": "success"}))
Exemplo n.º 2
0
 def test_set_living_cost_mark_nothing(self):
     SeveralCosts.objects.get(name="LivingCostMark").delete()
     SeveralCosts.set_living_cost_mark(1001)
     self.assertEqual(SeveralCosts.get_living_cost_mark(), 1001)
Exemplo n.º 3
0
 def test_set_living_cost_mark(self):
     SeveralCosts.set_living_cost_mark(1001)
     self.assertEqual(SeveralCosts.get_living_cost_mark(), 1001)