|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring,unsubscriptable-object |
3 | | -import time |
| 3 | +import unittest |
4 | 4 | from unittest.mock import patch |
5 | 5 | import numpy as np |
6 | 6 |
|
@@ -558,6 +558,32 @@ def test_meta_setting(self): |
558 | 558 | self.send_signal(self.widget.Inputs.data, data) |
559 | 559 | self.assertListEqual([c[0] for c in self.widget.conditions], vars_) |
560 | 560 |
|
| 561 | + def test_one_of_click(self): |
| 562 | + """Test items checked in is one of dropdown""" |
| 563 | + zoo = Table("zoo") |
| 564 | + self.send_signal(self.widget.Inputs.data, zoo) |
| 565 | + self.widget.remove_all_button.click() |
| 566 | + self.enterFilter(zoo.domain[1], "is one of") |
| 567 | + model = self.widget.cond_list.cellWidget(0, 2).popup.list_view.model() |
| 568 | + |
| 569 | + output = self.get_output(self.widget.Outputs.matching_data) |
| 570 | + self.assertEqual(len(zoo), len(output)) |
| 571 | + |
| 572 | + # check second item (group 1) - only 20 elements in this group |
| 573 | + model.item(1).setCheckState(Qt.Checked) |
| 574 | + output = self.get_output(self.widget.Outputs.matching_data) |
| 575 | + self.assertEqual(20, len(output)) |
| 576 | + |
| 577 | + # check first item (group 0) - now all elements should be at the output |
| 578 | + model.item(0).setCheckState(Qt.Checked) |
| 579 | + output = self.get_output(self.widget.Outputs.matching_data) |
| 580 | + self.assertEqual(len(zoo), len(output)) |
| 581 | + |
| 582 | + # uncheck second element (group 1) - only elements fo group 0 at output |
| 583 | + model.item(1).setCheckState(Qt.Unchecked) |
| 584 | + output = self.get_output(self.widget.Outputs.matching_data) |
| 585 | + self.assertEqual(81, len(output)) |
| 586 | + |
561 | 587 | def widget_with_context(self, domain, conditions): |
562 | 588 | ch = SelectRowsContextHandler() |
563 | 589 | context = ch.new_context(domain, *ch.encode_domain(domain)) |
@@ -612,3 +638,7 @@ def __set_value(widget, value): |
612 | 638 | widget.setDate(value) |
613 | 639 | else: |
614 | 640 | raise ValueError("Unsupported widget {}".format(widget)) |
| 641 | + |
| 642 | + |
| 643 | +if __name__ == "__main__": |
| 644 | + unittest.main() |
0 commit comments