From 49d492916a316f0843d9f9d5ddb52589acb2fc54 Mon Sep 17 00:00:00 2001 From: Ajda Date: Tue, 9 Jul 2024 14:42:04 +0200 Subject: [PATCH] Test custom format --- .../widgets/data/tests/test_oweditdomain.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Orange/widgets/data/tests/test_oweditdomain.py b/Orange/widgets/data/tests/test_oweditdomain.py index 26d792a02db..1a514652aa5 100644 --- a/Orange/widgets/data/tests/test_oweditdomain.py +++ b/Orange/widgets/data/tests/test_oweditdomain.py @@ -340,6 +340,34 @@ def test_time_variable_preservation(self): output = self.get_output(self.widget.Outputs.data) self.assertEqual(str(table[0, 4]), str(output[0, 4])) + def test_custom_format(self): + time_variable = StringVariable("Date") + data = [ + ["2024-001"], + ["2024-032"], + ["2024-150"], + ["2024-365"] + ] + table = Table.from_list(Domain([], metas=[time_variable]), data) + self.send_signal(self.widget.Inputs.data, table) + model = self.widget.domain_view.model() + index = self.widget.variables_view.model().index + self.widget.variables_view.setCurrentIndex(index(0)) + + editor = self.widget.findChild(TimeVariableEditor) + idx = editor.format_cb.count() - 1 + editor.format_cb.setCurrentIndex(idx) + editor.variable_changed.emit() + editor.custom_edit.setText("%Y-%j") + editor._on_custom_change() + model.setData(model.index(0, 0), [AsTime()], TransformRole) + + self.widget.commit() + output = self.get_output(self.widget.Outputs.data) + print(output.domain.metas) + self.assertEqual(str(table[0].metas[0]), "2024-001") + self.assertEqual(str(output[0].metas[0]), "2024-01-01") + def test_restore(self): iris = self.iris viris = (