Skip to content

Commit

Permalink
Test custom format
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Jul 9, 2024
1 parent bb7a898 commit 86c3c09
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Orange/widgets/data/tests/test_oweditdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 86c3c09

Please sign in to comment.