def test_remove_empty_household_members_middle_name_only_not_stored(self): schema = load_schema_from_params('census', 'household') unanswered = [ Answer(group_instance=0, answer_id='first-name', answer_instance=0, value=''), Answer(group_instance=0, answer_id='middle-names', answer_instance=0, value='should not be saved'), Answer(group_instance=0, answer_id='last-name', answer_instance=0, value='') ] for answer in unanswered: self.question_store.answer_store.add_or_update(answer) remove_empty_household_members_from_answer_store( self.question_store.answer_store, schema) for answer in unanswered: self.assertIsNone(self.question_store.answer_store.find(answer))
def test_remove_empty_household_members_partial_answers_are_stored(self): schema = load_schema_from_params('census', 'household') answered = [ Answer(group_instance=0, answer_id='first-name', answer_instance=0, value='Joe'), Answer(group_instance=0, answer_id='middle-names', answer_instance=0, value=''), Answer(group_instance=0, answer_id='last-name', answer_instance=0, value='Bloggs') ] partially_answered = [ Answer(group_instance=0, answer_id='first-name', answer_instance=1, value=''), Answer(group_instance=0, answer_id='middle-names', answer_instance=1, value=''), Answer(group_instance=0, answer_id='last-name', answer_instance=1, value='Last name only'), Answer(group_instance=0, answer_id='first-name', answer_instance=2, value='First name only'), Answer(group_instance=0, answer_id='middle-names', answer_instance=2, value=''), Answer(group_instance=0, answer_id='last-name', answer_instance=2, value='') ] answers = [] answers.extend(answered) answers.extend(partially_answered) for answer in answers: self.question_store.answer_store.add_or_update(answer) remove_empty_household_members_from_answer_store( self.question_store.answer_store, schema) for answer in answered: self.assertIsNotNone(self.question_store.answer_store.find(answer)) for answer in partially_answered: self.assertIsNotNone(self.question_store.answer_store.find(answer))