class PerimeterCurveMale(generics.RetrieveAPIView): """ Cephalic perimeter based growth curve for males aged 0 to 24 months view. """ serializer_class = PerimeterCurveSerializer def get_object(self): """ Get the specific curve. """ self.graphic = PerimeterCurve(gender=Constants.MALE) return self.graphic.make() def get_serializer_context(self): """ Insert some attribute inside serializer. """ context = super(PerimeterCurveMale, self).get_serializer_context() context['graphic'] = self.graphic.make_charts() return context
def get_object(self): """ Get the specific curve. """ self.graphic = PerimeterCurve(gender=Constants.FEMALE) return self.graphic.make()
def test_perimeter_curve_female(self): """ Test to verify if graphic construct is correct with FEMALE gender. """ graphic = PerimeterCurve(gender=Constants.FEMALE) self.assertEqual(graphic.make(), self.female) self.assertEqual(graphic.make(PerimeterCurve.TITLE), self.female['title'])
def test_result_invalid(self): """ Test to check if the result with age is incorrect. """ graphic = PerimeterCurve(gender=Constants.MALE) # percentis_3 self.assertEqual(graphic.result(30.13, 0), 0) self.assertEqual(graphic.result(30.13, -1), "Invalid age") self.assertEqual(graphic.result(43.08, 24), 0) self.assertEqual(graphic.result(43.08, 25), "Invalid age")
def get_graphic(self): """ Get the specific graphic. """ graphic = PerimeterCurve(gender=Constants.MALE) return graphic
def test_result_ok(self): """ Test to check if the result with age is correct. """ graphic = PerimeterCurve(gender=Constants.MALE) # percentis_3 self.assertEqual(graphic.result(30.12, 0), -1) self.assertEqual(graphic.result(30.13, 0), 0) self.assertEqual(graphic.result(30.14, 0), 0) self.assertEqual(graphic.result(40.63, 10), -1) self.assertEqual(graphic.result(40.64, 10), 0) self.assertEqual(graphic.result(40.65, 10), 0) # percentis_97 self.assertEqual(graphic.result(36.14, 0), 0) self.assertEqual(graphic.result(36.15, 0), 0) self.assertEqual(graphic.result(36.16, 0), 1) self.assertEqual(graphic.result(46.27, 10), 0) self.assertEqual(graphic.result(46.28, 10), 0) self.assertEqual(graphic.result(46.29, 10), 1)
def get_curve(cls, gender='M'): """ Get the specific curve from gender and interval. """ curve_gender = Constants.MALE if gender == 'F': curve_gender = Constants.FEMALE graphic = PerimeterCurve(gender=curve_gender) return graphic