def test_decimal_sign_fail(self, exp): exp.testpage += al.NumberEntry(name="number", decimal_signs=";") exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "1,12"}) assert not exp.testpage.number.validate_data()
def test_max(self, exp): exp.testpage += al.NumberEntry(name="number", max=2) exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "3"}) assert not exp.testpage.number.validate_data()
def test_string(self, exp): exp.testpage += al.NumberEntry(name="number", ndecimals=1) exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "test"}) assert not exp.testpage.number.validate_data()
def test_decimal_sign_semicolon_fail(self, exp): # validation fails, because ndecimals=0 default exp.testpage += al.NumberEntry(name="number", decimal_signs=";") exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "1;12"}) assert not exp.testpage.number.validate_data()
def test_ndecimals(self, exp): exp.testpage += al.NumberEntry(name="number", ndecimals=2) exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "1,12"}) assert exp.testpage.number.validate_data() assert exp.testpage.number.input == 1.12 assert exp.values.get("number") == 1.12
def test_integer(self, exp): exp.testpage += al.NumberEntry(name="number") exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "1"}) assert exp.testpage.number.validate_data() assert exp.testpage.number.input == 1 assert exp.values.get("number") == 1
def on_first_show(self): item = self.vargs.i position = self.position_in_section() stimulus = rivers[item] self.title = f"Task {position}" self += al.Text("Please estimate the length of the following river:", align="center") self += al.Text(f"**{stimulus}**", font_size="large", align="center") self += al.NumberEntry(placeholder="Enter a number", suffix="km", name=f"task_{position:02}") self += al.Value(stimulus, name=f"item_{position:02}")
def test_decimal_sign_semicolon(self, exp): # validation fails, because ndecimals=0 default exp.testpage += al.NumberEntry(name="number", decimal_signs=";", ndecimals=1) exp.start() exp.forward() exp.testpage.prepare_web_widget() exp.testpage._set_data({"number": "1;1"}) assert exp.testpage.number.validate_data() assert exp.testpage.number.input == 1.1 assert exp.values.get("number") == 1.1 # class TestMultipleChoiceList: # def test_data_select_one(self, exp): # exp.testpage += al.MultipleChoiceList("a", "b", name="test") # exp.start() # exp.forward() # exp.testpage.prepare_web_widget() # exp.testpage._set_data({f"test": ["1"]}) # assert exp.values["test"]["choice1"] == True # def test_data_select_multiple(self, exp): # exp.testpage += al.MultipleChoiceList("a", "b", name="test") # exp.start() # exp.forward() # exp.testpage.prepare_web_widget() # exp.testpage._set_data({f"test": ["1", "2"]}) # assert exp.values["test"]["choice1"] == True # assert exp.values["test"]["choice2"] == True