Exemple #1
0
 def test_valid_schema(self):
     """Test valid schema."""
     valid_schema = {
         "platform": "monoprice",
         "port": "/dev/ttyUSB0",
         "zones": {
             11: {
                 "name": "a"
             },
             12: {
                 "name": "a"
             },
             13: {
                 "name": "a"
             },
             14: {
                 "name": "a"
             },
             15: {
                 "name": "a"
             },
             16: {
                 "name": "a"
             },
             21: {
                 "name": "a"
             },
             22: {
                 "name": "a"
             },
             23: {
                 "name": "a"
             },
             24: {
                 "name": "a"
             },
             25: {
                 "name": "a"
             },
             26: {
                 "name": "a"
             },
             31: {
                 "name": "a"
             },
             32: {
                 "name": "a"
             },
             33: {
                 "name": "a"
             },
             34: {
                 "name": "a"
             },
             35: {
                 "name": "a"
             },
             36: {
                 "name": "a"
             },
         },
         "sources": {
             1: {
                 "name": "a"
             },
             2: {
                 "name": "a"
             },
             3: {
                 "name": "a"
             },
             4: {
                 "name": "a"
             },
             5: {
                 "name": "a"
             },
             6: {
                 "name": "a"
             },
         },
     }
     PLATFORM_SCHEMA(valid_schema)
 def test_valid_schema(self):
     """Test valid schema."""
     valid_schema = {
         'platform': 'monoprice',
         'port': '/dev/ttyUSB0',
         'zones': {
             11: {
                 'name': 'a'
             },
             12: {
                 'name': 'a'
             },
             13: {
                 'name': 'a'
             },
             14: {
                 'name': 'a'
             },
             15: {
                 'name': 'a'
             },
             16: {
                 'name': 'a'
             },
             21: {
                 'name': 'a'
             },
             22: {
                 'name': 'a'
             },
             23: {
                 'name': 'a'
             },
             24: {
                 'name': 'a'
             },
             25: {
                 'name': 'a'
             },
             26: {
                 'name': 'a'
             },
             31: {
                 'name': 'a'
             },
             32: {
                 'name': 'a'
             },
             33: {
                 'name': 'a'
             },
             34: {
                 'name': 'a'
             },
             35: {
                 'name': 'a'
             },
             36: {
                 'name': 'a'
             },
         },
         'sources': {
             1: {
                 'name': 'a'
             },
             2: {
                 'name': 'a'
             },
             3: {
                 'name': 'a'
             },
             4: {
                 'name': 'a'
             },
             5: {
                 'name': 'a'
             },
             6: {
                 'name': 'a'
             }
         }
     }
     PLATFORM_SCHEMA(valid_schema)
Exemple #3
0
 def test_invalid_schemas(self):
     """Test invalid schemas."""
     schemas = (
         {},  # Empty
         None,  # None
         # Missing port
         {
             "platform": "monoprice",
             "name": "Name",
             "zones": {
                 11: {
                     "name": "a"
                 }
             },
             "sources": {
                 1: {
                     "name": "b"
                 }
             },
         },
         # Invalid zone number
         {
             "platform": "monoprice",
             "port": "aaa",
             "name": "Name",
             "zones": {
                 10: {
                     "name": "a"
                 }
             },
             "sources": {
                 1: {
                     "name": "b"
                 }
             },
         },
         # Invalid source number
         {
             "platform": "monoprice",
             "port": "aaa",
             "name": "Name",
             "zones": {
                 11: {
                     "name": "a"
                 }
             },
             "sources": {
                 0: {
                     "name": "b"
                 }
             },
         },
         # Zone missing name
         {
             "platform": "monoprice",
             "port": "aaa",
             "name": "Name",
             "zones": {
                 11: {}
             },
             "sources": {
                 1: {
                     "name": "b"
                 }
             },
         },
         # Source missing name
         {
             "platform": "monoprice",
             "port": "aaa",
             "name": "Name",
             "zones": {
                 11: {
                     "name": "a"
                 }
             },
             "sources": {
                 1: {}
             },
         },
     )
     for value in schemas:
         with pytest.raises(vol.MultipleInvalid):
             PLATFORM_SCHEMA(value)
 def test_invalid_schemas(self):
     """Test invalid schemas."""
     schemas = (
         {},  # Empty
         None,  # None
         # Missing port
         {
             'platform': 'monoprice',
             'name': 'Name',
             'zones': {
                 11: {
                     'name': 'a'
                 }
             },
             'sources': {
                 1: {
                     'name': 'b'
                 }
             },
         },
         # Invalid zone number
         {
             'platform': 'monoprice',
             'port': 'aaa',
             'name': 'Name',
             'zones': {
                 10: {
                     'name': 'a'
                 }
             },
             'sources': {
                 1: {
                     'name': 'b'
                 }
             },
         },
         # Invalid source number
         {
             'platform': 'monoprice',
             'port': 'aaa',
             'name': 'Name',
             'zones': {
                 11: {
                     'name': 'a'
                 }
             },
             'sources': {
                 0: {
                     'name': 'b'
                 }
             },
         },
         # Zone missing name
         {
             'platform': 'monoprice',
             'port': 'aaa',
             'name': 'Name',
             'zones': {
                 11: {}
             },
             'sources': {
                 1: {
                     'name': 'b'
                 }
             },
         },
         # Source missing name
         {
             'platform': 'monoprice',
             'port': 'aaa',
             'name': 'Name',
             'zones': {
                 11: {
                     'name': 'a'
                 }
             },
             'sources': {
                 1: {}
             },
         },
     )
     for value in schemas:
         with pytest.raises(vol.MultipleInvalid):
             PLATFORM_SCHEMA(value)