|
| 1 | +# Copyright Contributors to the OpenCue Project |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +"""Tests for cuegui.TagsWidget.""" |
| 17 | + |
| 18 | + |
| 19 | +import unittest |
| 20 | + |
| 21 | +import cuegui.TagsWidget |
| 22 | + |
| 23 | + |
| 24 | +class IsValidTagTests(unittest.TestCase): |
| 25 | + """Tests for TagsWidget._is_valid_tag method.""" |
| 26 | + |
| 27 | + def test_alphanumeric_tag(self): |
| 28 | + """Standard alphanumeric tags should be valid.""" |
| 29 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('general')) |
| 30 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag123')) |
| 31 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('UPPERCASE')) |
| 32 | + |
| 33 | + def test_tag_with_dashes(self): |
| 34 | + """Tags containing dashes should be valid.""" |
| 35 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('test-layer-tag')) |
| 36 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('my-tag')) |
| 37 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('a-b-c')) |
| 38 | + |
| 39 | + def test_tag_with_underscores(self): |
| 40 | + """Tags containing underscores should be valid.""" |
| 41 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('my_tag')) |
| 42 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('test_layer_tag')) |
| 43 | + |
| 44 | + def test_mixed_characters(self): |
| 45 | + """Tags with mixed valid characters should be valid.""" |
| 46 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('MixedCase-123')) |
| 47 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag_with-both')) |
| 48 | + self.assertTrue(cuegui.TagsWidget.TagsWidget._is_valid_tag('GPU-v100_render')) |
| 49 | + |
| 50 | + def test_empty_tag(self): |
| 51 | + """Empty tags should be invalid.""" |
| 52 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('')) |
| 53 | + |
| 54 | + def test_tag_with_spaces(self): |
| 55 | + """Tags containing spaces should be invalid.""" |
| 56 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag with space')) |
| 57 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag(' leading')) |
| 58 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('trailing ')) |
| 59 | + |
| 60 | + def test_tag_with_special_characters(self): |
| 61 | + """Tags containing special characters should be invalid.""" |
| 62 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag@special')) |
| 63 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag!')) |
| 64 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag#hash')) |
| 65 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag.dot')) |
| 66 | + self.assertFalse(cuegui.TagsWidget.TagsWidget._is_valid_tag('tag/slash')) |
| 67 | + |
| 68 | + |
| 69 | +if __name__ == '__main__': |
| 70 | + unittest.main() |
0 commit comments