def test_basic_get_headers(self): column = SplitExportColumn( label="Fruit", item=MultipleChoiceItem( options=[Option(value='Apple'), Option(value='Banana')] ), ignore_unspecified_options=True ) self.assertEqual(column.get_headers(), ["Fruit | Apple", "Fruit | Banana"])
def test_get_headers_with_extras(self): column = SplitExportColumn( label="Fruit - {option}", item=MultipleChoiceItem( options=[Option(value='Apple'), Option(value='Banana')] ), ignore_unspecified_options=False ) self.assertEqual(column.get_headers(), ["Fruit - Apple", "Fruit - Banana", "Fruit - extra"])
def test_ignore_extas(self): column = SplitExportColumn( item=MultipleChoiceItem( path=['form', 'q1'], options=[Option(value='a'), Option(value='c')] ), ignore_unspecified_options=True ) doc = {"q1": "a b d"} self.assertEqual(column.get_value(doc, ["form"]), [1, None])