Exemple #1
0
    def test_ids_are_diff_when_keys_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 #1"

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

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

        register_widget(
            "text_input",
            element1.text_input,
            user_key="some_key1",
            ctx=self.new_script_run_ctx,
        )
        register_widget(
            "text_input",
            element2.text_input,
            user_key="some_key2",
            ctx=self.new_script_run_ctx,
        )

        self.assertNotEqual(element1.text_input.id, element2.text_input.id)
Exemple #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)
Exemple #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)
    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)
        _set_widget_id("text_input", element2)

        self.assertEqual(element1.text_input.id, element2.text_input.id)
Exemple #5
0
    def test_ids_are_diff_when_labels_are_diff(self):
        text_input1 = TextInput()
        text_input1.label = "Label #1"
        text_input1.default = "Value #1"

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

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

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

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

        self.assertNotEqual(element1.text_input.id, element2.text_input.id)
Exemple #6
0
    def test_ids_are_equal_when_keys_are_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)

        register_widget("text_input", element1.text_input, user_key="some_key")

        with self.assertRaises(DuplicateWidgetID):
            register_widget("text_input", element2.text_input, user_key="some_key")
Exemple #7
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)

        register_widget("text_input",
                        element1.text_input,
                        ctx=self.new_script_run_ctx)

        with self.assertRaises(DuplicateWidgetID):
            register_widget("text_input",
                            element2.text_input,
                            ctx=self.new_script_run_ctx)
Exemple #8
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)
Exemple #9
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)

        register_widget("text_input",
                        element1.text_input,
                        ctx=self.new_script_run_ctx)
        register_widget("text_input",
                        element2.text_input,
                        ctx=self.new_script_run_ctx)

        self.assertNotEqual(element1.text_input.id, element2.text_area.id)