Add Google pubsub component (#20049)
* Add google pubsub component * Add tests and requirements * Make python3.5 compatible * Fix linting * Fix pubsub test * Code review comments * Add missing docstrings * Update requirements_all * Code review comment - Remove pylint ignores - Don't modify global environment
This commit is contained in:
1 parent
1ebdc2e2c2
commit
d049b521b2
3 files changed
+124
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"""The tests for the Google Pub/Sub component."""
|
||||
from datetime import datetime
|
||||
|
||||
from homeassistant.components.google_pubsub import (
|
||||
DateTimeJSONEncoder as victim)
|
||||
|
||||
|
||||
class TestDateTimeJSONEncoder(object):
|
||||
"""Bundle for DateTimeJSONEncoder tests."""
|
||||
|
||||
def test_datetime(self):
|
||||
"""Test datetime encoding."""
|
||||
time = datetime(2019, 1, 13, 12, 30, 5)
|
||||
assert victim().encode(time) == '"2019-01-13T12:30:05"'
|
||||
|
||||
def test_no_datetime(self):
|
||||
"""Test integer encoding."""
|
||||
assert victim().encode(42) == '42'
|
||||
|
||||
def test_nested(self):
|
||||
"""Test dictionary encoding."""
|
||||
assert victim().encode({'foo': 'bar'}) == '{"foo": "bar"}'
|
||||
Reference in new issue
Block a user