Пример #1
0
    def test_ids_are_diff_when_types_are_diff(self):
        text_input1 = TextInput()
        text_input1.label = "Label #1"
        text_input1.default = "Value #1"

        text_area2 = TextArea()
        text_area2.label = "Label #1"
        text_area2.default = "Value #1"

        element1 = Element()
        element1.text_input.CopyFrom(text_input1)

        element2 = Element()
        element2.text_area.CopyFrom(text_area2)

        _set_widget_id("text_input", element1.text_input)
        _set_widget_id("text_input", element2.text_input)

        self.assertNotEqual(element1.text_input.id, element2.text_area.id)
Пример #2
0
    def test_ids_are_diff_when_values_are_diff(self):
        text_input1 = TextInput()
        text_input1.label = "Label #1"
        text_input1.default = "Value #1"

        text_input2 = TextInput()
        text_input2.label = "Label #1"
        text_input2.default = "Value #2"

        element1 = Element()
        element1.text_input.CopyFrom(text_input1)

        element2 = Element()
        element2.text_input.CopyFrom(text_input2)

        _set_widget_id("text_input", element1.text_input, user_key="some_key1")
        _set_widget_id("text_input", element2.text_input, user_key="some_key1")

        self.assertNotEqual(element1.text_input.id, element2.text_input.id)
Пример #3
0
    def test_ids_are_equal_when_proto_is_equal(self):
        text_input1 = TextInput()
        text_input1.label = "Label #1"
        text_input1.default = "Value #1"

        text_input2 = TextInput()
        text_input2.label = "Label #1"
        text_input2.default = "Value #1"

        element1 = Element()
        element1.text_input.CopyFrom(text_input1)

        element2 = Element()
        element2.text_input.CopyFrom(text_input2)

        _set_widget_id("text_input", element1.text_input)

        with self.assertRaises(DuplicateWidgetID):
            _set_widget_id("text_input", element2.text_input)