Esempio n. 1
0
    def test_height_curve_female_years(self):
        """
        Test to verify if graphic construct is correct with FEMALE and YEARS.
        """

        graphic = HeightCurve(gender=Constants.FEMALE, age=Constants.YEARS)
        self.assertEqual(graphic.make(), self.female_years)
        self.assertEqual(graphic.make(HeightCurve.TITLE),
                         self.female_years['title'])
Esempio n. 2
0
    def test_height_curve_male_months(self):
        """
        Test to verify if graphic construct is correct with MALE and MONTHS.
        """

        graphic = HeightCurve(gender=Constants.MALE, age=Constants.MONTHS)
        self.assertEqual(graphic.make(), self.male_months)
        self.assertEqual(graphic.make(HeightCurve.TITLE),
                         self.male_months['title'])
Esempio n. 3
0
class HeightCurveFemaleYears(generics.RetrieveAPIView):
    """
    Height-based growth curve for females aged 3 to 20 years view.
    """

    serializer_class = HeightCurveSerializer

    def get_object(self):
        """
        Get the specific curve.
        """

        self.graphic = HeightCurve(gender=Constants.FEMALE,
                                   age=Constants.YEARS)

        return self.graphic.make()

    def get_serializer_context(self):
        """
        Insert some attribute inside serializer.
        """

        context = super(HeightCurveFemaleYears, self).get_serializer_context()
        context['graphic'] = self.graphic.make_charts(years=True)

        return context
Esempio n. 4
0
class HeightCurveMaleMonths(generics.RetrieveAPIView):
    """
    Height-based growth curve for males aged 0 to 36 months view.
    """

    serializer_class = HeightCurveSerializer

    def get_object(self):
        """
        Get the specific curve.
        """

        self.graphic = HeightCurve(gender=Constants.MALE, age=Constants.MONTHS)

        return self.graphic.make()

    def get_serializer_context(self):
        """
        Insert some attribute inside serializer.
        """

        context = super(HeightCurveMaleMonths, self).get_serializer_context()
        context['graphic'] = self.graphic.make_charts()

        return context