Ejemplo n.º 1
0
    def test_select_item_with_default(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)

        # Make sure we start with an empty list
        assert selector.selected.GetCount() == 0

        # Select the "default" SeriesDescription
        selector.options.SetSelection(2)

        # Trigger the SelectItem callback
        selector.SelectItem()

        assert selector.selected.GetStrings() == ['SeriesDescription']

        # Select another field
        selector.options.SetSelection(0)

        # Trigger the SelectItem callback
        selector.SelectItem()

        # SeriesDescription should remain at the bottom
        assert selector.selected.GetStrings() == ['PatientName', 'SeriesDescription']

        # Select another field
        selector.options.SetSelection(1)

        # Trigger the SelectItem callback
        selector.SelectItem()

        # SeriesDescription should remain at the bottom
        assert selector.selected.GetStrings() == ['PatientName', 'PatientID', 'SeriesDescription']
Ejemplo n.º 2
0
    def test_get_format_fields(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)
        selector.selected.SetItems(choices)

        expected = ['%(PatientName)s', '%(PatientID)s', '%(SeriesDescription)s']
        assert selector.GetFormatFields() == expected
Ejemplo n.º 3
0
    def test_select_item(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)

        # Make sure we start with an empty list
        assert selector.selected.GetCount() == 0

        # Select the item in the options
        selector.options.SetSelection(0)

        # Trigger the SelectItem callback
        selector.SelectItem()

        # Make sure that it added this item to the selected list
        items = selector.selected.GetStrings()

        assert items == ['PatientName']

        # Select another item in the options
        selector.options.SetSelection(1)

        # Trigger the SelectItem callback
        selector.SelectItem()

        # Make sure that it added this item to the selected list
        items = selector.selected.GetStrings()

        assert items == ['PatientName', 'PatientID']
Ejemplo n.º 4
0
    def test_deselect_item_no_selection(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)
        selector.selected.SetItems(choices)

        selector.DeselectItem()

        assert selector.selected.GetStrings() == choices
Ejemplo n.º 5
0
    def test_filter(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)

        assert selector.options.GetStrings() == choices

        selector.Filter('atient')

        assert selector.options.GetStrings() == ['PatientName', 'PatientID']
Ejemplo n.º 6
0
    def test_has_default_series_description_selected(self):
        selector = FieldSelector(self.frame)

        # Add "SeriesDescription" to the top of the Selected list
        selector.selected.Insert('SeriesDescription', 0)

        # Add another field below "SeriesDescription"
        selector.selected.Insert('PatientName', 0)

        assert selector.has_default() is True
Ejemplo n.º 7
0
    def test_promote_selection_with_default(self):
        choices = ['one', 'two', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)

        selector.selected.SetItems(choices)

        # Try to promote the default
        selector.selected.SetStringSelection(choices[2])
        selector.PromoteSelection()

        # The ordering remained unchanged
        assert selector.selected.GetStrings() == choices
Ejemplo n.º 8
0
    def test_set_options(self):
        original_choices = ['one', 'two', 'three']
        selector = FieldSelector(self.frame, choices=original_choices)

        assert selector.options.GetStrings() == original_choices
        assert selector.choices == original_choices

        new_choices = ['four', 'five', 'six']
        selector.SetOptions(new_choices)

        assert selector.options.GetStrings() == new_choices
        assert selector.choices == new_choices
Ejemplo n.º 9
0
    def test_demote_selection(self):
        choices = ['one', 'two', 'three']
        selector = FieldSelector(self.frame, choices=choices)

        selector.selected.SetItems(choices)

        # Demote the first one
        selector.selected.SetStringSelection(choices[0])
        selector.DemoteSelection()

        assert selector.selected.GetStrings() == ['two', 'one', 'three']

        # Demote again
        selector.DemoteSelection()

        assert selector.selected.GetStrings() == ['two', 'three', 'one']

        # Try to demote again
        selector.DemoteSelection()

        assert selector.selected.GetStrings() == ['two', 'three', 'one']
Ejemplo n.º 10
0
    def test_promote_selection(self):
        choices = ['one', 'two', 'three']
        selector = FieldSelector(self.frame, choices=choices)

        selector.selected.SetItems(choices)

        # Promote the last one
        selector.selected.SetStringSelection(choices[2])
        selector.PromoteSelection()

        assert selector.selected.GetStrings() == ['one', 'three', 'two']

        # Promote again
        selector.PromoteSelection()

        assert selector.selected.GetStrings() == ['three', 'one', 'two']

        # Try to Promote again
        selector.PromoteSelection()

        assert selector.selected.GetStrings() == ['three', 'one', 'two']
Ejemplo n.º 11
0
    def test_constructor(self):
        choices = ['one', 'two', 'three']
        selector = FieldSelector(self.frame, choices=choices)

        assert isinstance(selector, FieldSelector)
Ejemplo n.º 12
0
    def test_has_default_none_selected(self):
        choices = ['PatientName', 'PatientID', 'SeriesDescription']
        selector = FieldSelector(self.frame, choices=choices)

        assert selector.has_default() is False
Ejemplo n.º 13
0
    def test_enable_all(self):
        selector = FieldSelector(self.frame)
        selector.EnableAll()

        for widget in selector.WidgetList():
            assert widget.IsEnabled() is True