Esempio n. 1
0
 def test_get_category_data(self):
     month_data = Data.get_month_data(2000, 1)
     data = Data.get_category_data(month_data, 1)
     expects = [
         "コンビニ",
         "スーパー",
         "立替分1"
     ]
     self._assert_list(data, expects)
Esempio n. 2
0
    def get(self, request, *args, **kwargs):
        # validation
        if "year" in request.GET and "month" in request.GET:
            year = request.GET.get("year")
            month = request.GET.get("month")
            if not is_valid_date(year, month):
                return HttpResponseBadRequest("parameter error")
        else:
            return HttpResponseBadRequest("parameter error")

        # 今月のデータ
        monthly_data = Data.get_month_data(int(year), int(month))
        # ジャンルごとの支出
        positive_categories_outgo = {}
        for c in Category.list():
            if c.show_order >= 0:
                d = Data.get_category_data(monthly_data, c.pk)
                positive_categories_outgo[
                    c.name] = Data.get_outgo_sum(d) - Data.get_temp_sum(d)
        context = {
            'categories_outgo': positive_categories_outgo,
        }
        return render(request, '_chart_container_data.html', context)
Esempio n. 3
0
 def test_get_category_data_empty(self):
     month_data = Data.get_month_data(1999, 1)
     data = Data.get_category_data(month_data, 1)
     self.assertEqual(data.count(), 0)
Esempio n. 4
0
 def test_get_category_data_nothing(self):
     month_data = Data.get_month_data(2000, 1)
     data = Data.get_category_data(month_data, 1000)
     self.assertEqual(data.count(), 0)