Skip to content

Commit 49d4929

Browse files
committed
Test custom format
1 parent f5404fe commit 49d4929

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Orange/widgets/data/tests/test_oweditdomain.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,34 @@ def test_time_variable_preservation(self):
340340
output = self.get_output(self.widget.Outputs.data)
341341
self.assertEqual(str(table[0, 4]), str(output[0, 4]))
342342

343+
def test_custom_format(self):
344+
time_variable = StringVariable("Date")
345+
data = [
346+
["2024-001"],
347+
["2024-032"],
348+
["2024-150"],
349+
["2024-365"]
350+
]
351+
table = Table.from_list(Domain([], metas=[time_variable]), data)
352+
self.send_signal(self.widget.Inputs.data, table)
353+
model = self.widget.domain_view.model()
354+
index = self.widget.variables_view.model().index
355+
self.widget.variables_view.setCurrentIndex(index(0))
356+
357+
editor = self.widget.findChild(TimeVariableEditor)
358+
idx = editor.format_cb.count() - 1
359+
editor.format_cb.setCurrentIndex(idx)
360+
editor.variable_changed.emit()
361+
editor.custom_edit.setText("%Y-%j")
362+
editor._on_custom_change()
363+
model.setData(model.index(0, 0), [AsTime()], TransformRole)
364+
365+
self.widget.commit()
366+
output = self.get_output(self.widget.Outputs.data)
367+
print(output.domain.metas)
368+
self.assertEqual(str(table[0].metas[0]), "2024-001")
369+
self.assertEqual(str(output[0].metas[0]), "2024-01-01")
370+
343371
def test_restore(self):
344372
iris = self.iris
345373
viris = (

0 commit comments

Comments
 (0)