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 10, 2024
1 parent bb7a898 commit 7143ecd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Orange/widgets/data/tests/test_oweditdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# pylint: disable=all
import pickle
import unittest
from datetime import datetime, timezone
from functools import partial
from itertools import product, chain
from unittest import TestCase
Expand Down Expand Up @@ -340,6 +341,38 @@ 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)
index = self.widget.variables_view.model().index
self.widget.variables_view.setCurrentIndex(index(0))

editor = self.widget.findChild(VariableEditor)
tc = editor.layout().currentWidget().findChild(QComboBox,
name="type-combo")
tc.setCurrentIndex(3) # time variable
tc.activated.emit(3)

# le = editor.layout().currentWidget().findChild(QLineEdit)
# le.setText("%Y-%j")
# le.editingFinished.emit()

self.widget.commit()
output = self.get_output(self.widget.Outputs.data)
print(output)
self.assertEqual(table.metas[0, 0], "2024-001")
self.assertEqual(output.metas[0, 0],
datetime.strptime("2024-001",
"%Y-%j").replace(
tzinfo=timezone.utc).timestamp())

def test_restore(self):
iris = self.iris
viris = (
Expand Down

0 comments on commit 7143ecd

Please sign in to comment.