Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test File: Disallow changing string columns to datetime #2120

Merged
merged 1 commit into from
Mar 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Orange/widgets/data/tests/test_owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

from AnyQt.QtCore import QMimeData, QPoint, Qt, QUrl
from AnyQt.QtGui import QDragEnterEvent, QDropEvent
from AnyQt.QtWidgets import QComboBox

import Orange
from Orange.data import FileFormat, dataset_dirs, StringVariable, Table, \
Domain, DiscreteVariable
from Orange.tests import named_file
from Orange.widgets.data.owfile import OWFile
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.utils.domaineditor import ComboDelegate, VarTypeDelegate, VarTableModel

TITANIC_PATH = path.join(path.dirname(Orange.__file__), 'datasets', 'titanic.tab')

Expand Down Expand Up @@ -165,3 +167,31 @@ def test_context_match_includes_variable_values(self):
with named_file(file2, suffix=".tab") as filename:
self.open_dataset(filename)
self.assertEqual(editor.model().data(idx, Qt.DisplayRole), "a, b, c")

def test_check_datetime_disabled(self):
"""
Datetime option is disable if numerical is disabled as well.
GH-2050 (code fixes)
GH-2120
"""
dat = """\
01.08.16\t42.15\tneumann\t2017-02-20
03.08.16\t16.08\tneumann\t2017-02-21
04.08.16\t23.04\tneumann\t2017-02-22
03.09.16\t48.84\tturing\t2017-02-23
02.02.17\t23.16\tturing\t2017-02-24"""
with named_file(dat, suffix=".tab") as filename:
self.open_dataset(filename)
domain_editor = self.widget.domain_editor
idx = lambda x: self.widget.domain_editor.model().createIndex(x, 1)

qcombobox = QComboBox()
combo = ComboDelegate(domain_editor,
VarTableModel.typenames).createEditor(qcombobox, None, idx(2))
vartype_delegate = VarTypeDelegate(domain_editor, VarTableModel.typenames)

vartype_delegate.setEditorData(combo, idx(2))
counts = [4, 2, 4, 2]
for i in range(4):
vartype_delegate.setEditorData(combo, idx(i))
self.assertEqual(combo.count(), counts[i])