def marriageAllowed(family, husband, wife): allowableMarriage = True marriageDate = utils.calcDate(family["MARR"][0]) wifeAgeAtMarriage = utils.calculateAge(wife, marriageDate) husbandAgeAtMarriage = utils.calculateAge(husband, marriageDate) if wifeAgeAtMarriage < 14 or husbandAgeAtMarriage < 14: allowableMarriage = False return allowableMarriage
def checkForDiff(family, husband, wife): allowableMarriage = True marriageDate = utils.calcDate(family["MARR"][0]) wifeAgeAtMarriage = utils.calculateAge(wife, marriageDate) husbandAgeAtMarriage = utils.calculateAge(husband, marriageDate) ageDifference = abs(wifeAgeAtMarriage - husbandAgeAtMarriage) if (((wifeAgeAtMarriage > husbandAgeAtMarriage) and (ageDifference >= husbandAgeAtMarriage)) or ((wifeAgeAtMarriage < husbandAgeAtMarriage) and (ageDifference >= wifeAgeAtMarriage))): allowableMarriage = False return allowableMarriage
def test_addAge(self): currentDate = datetime.date.today() indAge = utils.calculateAge(self.underageInd, currentDate) includeAge.addAgeToIndividual(self.underageInd) self.assertTrue("AGE" in self.underageInd.keys(), "Age was not added") self.assertEqual(indAge, self.underageInd["AGE"], "This individual should be %d years old" % (indAge))
def test_calcAge(self): currentDate = datetime.date(2000, 8, 10) calculatedAge = utils.calculateAge(self.individual, currentDate) self.assertEqual( calculatedAge, 30, 'Age was calculated as %d, when it was supposed to be 30' % (calculatedAge))
def addAgeToIndividual(individual): currentDate = datetime.date.today() indAge = utils.calculateAge(individual, currentDate) individual["AGE"] = indAge return