Skip to content

Commit

Permalink
Added test and changed to reflect new Error name
Browse files Browse the repository at this point in the history
  • Loading branch information
rokgomiscek committed Jan 24, 2020
1 parent 0d348df commit e52b104
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions Orange/widgets/unsupervised/tests/test_owtsne.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,49 +70,57 @@ def restore_mocked_functions(self):

def test_wrong_input(self):
# no data
self.data = None
self.send_signal(self.widget.Inputs.data, self.data)
data = None
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNone(self.widget.data)

# <2 rows
self.data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1']])
self.send_signal(self.widget.Inputs.data, self.data)
data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1']])
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNone(self.widget.data)
self.assertTrue(self.widget.Error.not_enough_rows.is_shown())

# no attributes
self.data = Table.from_list(self.empty_domain, [['STG1']] * 2)
self.send_signal(self.widget.Inputs.data, self.data)
data = Table.from_list(self.empty_domain, [['STG1']] * 2)
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNone(self.widget.data)
self.assertTrue(self.widget.Error.no_attributes.is_shown())
self.assertTrue(self.widget.Error.not_enough_cols.is_shown())

# one attributes
data = Table.from_list(self.empty_domain, [[1, 'STG1'],
[2, 'STG1']])
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNone(self.widget.data)
self.assertTrue(self.widget.Error.not_enough_cols.is_shown())

# constant data
self.data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1']] * 2)
self.send_signal(self.widget.Inputs.data, self.data)
data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1']] * 2)
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNone(self.widget.data)
self.assertTrue(self.widget.Error.constant_data.is_shown())

# correct input
self.data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1'],
[5, 4, 3, 2, 1, 'STG1']])
self.send_signal(self.widget.Inputs.data, self.data)
data = Table.from_list(self.domain, [[1, 2, 3, 4, 5, 'STG1'],
[5, 4, 3, 2, 1, 'STG1']])
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()
self.assertIsNotNone(self.widget.data)
self.assertFalse(self.widget.Error.not_enough_rows.is_shown())
self.assertFalse(self.widget.Error.no_attributes.is_shown())
self.assertFalse(self.widget.Error.not_enough_cols.is_shown())
self.assertFalse(self.widget.Error.constant_data.is_shown())

def test_input(self):
self.data = Table.from_list(self.domain, [[1, 1, 1, 1, 1, 'STG1'],
[2, 2, 2, 2, 2, 'STG1'],
[4, 4, 4, 4, 4, 'STG2'],
[5, 5, 5, 5, 5, 'STG2']])
data = Table.from_list(self.domain, [[1, 1, 1, 1, 1, 'STG1'],
[2, 2, 2, 2, 2, 'STG1'],
[4, 4, 4, 4, 4, 'STG2'],
[5, 5, 5, 5, 5, 'STG2']])

self.send_signal(self.widget.Inputs.data, self.data)
self.send_signal(self.widget.Inputs.data, data)
self.wait_until_stop_blocking()

def test_attr_models(self):
Expand Down

0 comments on commit e52b104

Please sign in to comment.