aioupnp/tests/test_case_insensitive.py

46 lines
1.6 KiB
Python
Raw Normal View History

2018-10-25 01:16:17 +02:00
import unittest
from aioupnp.device import CaseInsensitive
2020-10-30 20:12:39 +01:00
class _TestService(CaseInsensitive):
2018-10-25 01:16:17 +02:00
serviceType = None
serviceId = None
controlURL = None
eventSubURL = None
SCPDURL = None
class TestCaseInsensitive(unittest.TestCase):
def test_initialize(self):
2020-10-30 20:12:39 +01:00
s = _TestService(
2018-10-25 01:16:17 +02:00
serviceType="test", serviceId="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
)
self.assertEqual('test', getattr(s, 'serviceType'))
self.assertEqual('test', getattr(s, 'servicetype'))
self.assertEqual('test', getattr(s, 'SERVICETYPE'))
2020-10-30 20:12:39 +01:00
s = _TestService(
2018-10-25 01:16:17 +02:00
servicetype="test", serviceid="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
)
self.assertEqual('test', getattr(s, 'serviceType'))
self.assertEqual('test', getattr(s, 'servicetype'))
self.assertEqual('test', getattr(s, 'SERVICETYPE'))
self.assertDictEqual({
'serviceType': 'test',
'serviceId': 'test id',
'controlURL': "/test",
'eventSubURL': "/test2",
'SCPDURL': "/test3"
}, s.as_dict())
def test_set_attr(self):
2020-10-30 20:12:39 +01:00
s = _TestService(
2018-10-25 01:16:17 +02:00
serviceType="test", serviceId="test id", controlURL="/test", eventSubURL="/test2", SCPDURL="/test3"
)
self.assertEqual('test', getattr(s, 'serviceType'))
s.servicetype = 'foo'
self.assertEqual('foo', getattr(s, 'serviceType'))
self.assertEqual('foo', getattr(s, 'servicetype'))
self.assertEqual('foo', getattr(s, 'SERVICETYPE'))