def get_additional_options(cls): """Additional options for TreasureHuntResourceGenerator.""" return { "prefilled_values": EnumResourceParameter(name="prefilled_values", description=_("Prefill with Numbers"), values=PREFILLED_VALUES_VALUES, default="easy"), "number_order": EnumResourceParameter(name="number_order", description=_("Numbers Unsorted/Sorted"), values=NUMBER_ORDER_VALUES, default="sorted"), "instructions": BoolResourceParameter(name="instructions", description=_("Include instruction sheets"), default=True), "art": EnumResourceParameter(name="art", description=_("Printing mode"), values=ART_VALUES, default="bw"), }
def test_enum_resource_parameter_html_element(self): values = {"value1": "Value 1", "value2": "Value 2"} param = EnumResourceParameter( name="option1", values=values, default="value2", description="option1 description" ) html = param.html_element() self.assertIsInstance(html, etree._Element) self.assertEqual("fieldset", html.tag) self.assertEqual(3, len(html)) # legend, div, div self.assertEqual("legend", html[0].tag) self.assertEqual("option1 description", html[0].text) self.assertEqual("div", html[1].tag) self.assertEqual("input", html[1][0].tag) self.assertEqual("option1", html[1][0].get("name")) self.assertEqual("value1", html[1][0].get("value")) self.assertEqual("radio", html[1][0].get("type")) self.assertEqual(None, html[1][0].get("checked")) # Not the default self.assertEqual("label", html[1][1].tag) self.assertEqual("Value 1", html[1][1].text) self.assertEqual("div", html[2].tag) self.assertEqual("input", html[2][0].tag) self.assertEqual("option1", html[2][0].get("name")) self.assertEqual("value2", html[2][0].get("value")) self.assertEqual("radio", html[2][0].get("type")) self.assertEqual("checked", html[2][0].get("checked")) # default self.assertEqual("label", html[2][1].tag) self.assertEqual("Value 2", html[2][1].text)
def get_options(cls): """Get options dictionary, including additional subclass options. Returns: Dictionary, of form {option name: ResourceParameter object, ...} """ options = cls.get_additional_options() options.update({ "paper_size": EnumResourceParameter(name="paper_size", description=_("Paper Size"), values=PAPER_SIZE_VALUES, default="a4"), }) return options
def get_additional_options(cls): """Additional options for BinaryCardsSmallResourceGenerator.""" return { "number_bits": EnumResourceParameter(name="number_bits", description=_("Number of Bits"), values=NUMBER_BITS_VALUES, default="4"), "dot_counts": BoolResourceParameter( name="dot_counts", description=_("Display Dot Counts"), default=True, ), "black_back": BoolResourceParameter( name="black_back", description=_("Black on Card Back"), default=False, true_text= _("Yes - Uses a lot of black ink, but conveys clearer card state. Print double sided." ), false_text=_("No - Print single sided.")) }
def test_enum_resource_parameter_index(self): param = EnumResourceParameter(values={"1": "One", "2": "Two", "3": "Three"}) self.assertEqual(1, param.index("2")) # Index of value 2 in the dict
def test_enum_resource_parameter_process_value_invalid_value(self): param = EnumResourceParameter(values={"value1": "Value 1"}) with self.assertRaises(QueryParameterInvalidError): param.process_value("invalid")
def test_enum_resource_parameter_process_value_valid_value(self): param = EnumResourceParameter(values={"value1": "Value 1"}) processed = param.process_value("value1") self.assertEqual("value1", processed) # Returned unchanged