diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-07-24 00:55:33 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-07-24 00:58:37 +0200 |
commit | 8f54b1960e2050536f34f091c1de291febd486df (patch) | |
tree | 63de297dc93365e67cb2e0af2ee81e9d94e9fabb /pyinflux/test/test_client.py | |
parent | fbb91144484ad729c2d6b54c69d4ce3a6c80aa55 (diff) | |
download | pyinflux-master.tar.gz pyinflux-master.zip |
fix small bug with parsing quoted escaped escapes
Diffstat (limited to 'pyinflux/test/test_client.py')
-rw-r--r-- | pyinflux/test/test_client.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pyinflux/test/test_client.py b/pyinflux/test/test_client.py new file mode 100644 index 0000000..2c9108f --- /dev/null +++ b/pyinflux/test/test_client.py @@ -0,0 +1,36 @@ +import json +import codecs +from unittest import TestCase +from pyinflux.client import Line, QueryResultOption +from io import BytesIO + + +class TestLine(TestCase): + def test_line(self): + self.assertEqual(str(Line('test', [('a', 'b')], [('value', 'asd\\\\')])), + r'test,a=b value="asd\\\\"') + + self.assertEqual(repr(Line('test', [('a', 'b')], [('value', 'asd\\\\')])), + r"<Line key=test tags=[('a', 'b')] fields=[('value', 'asd\\\\')] timestamp=None>") + + +class TestQueryResultOption(TestCase): + def test_json(self): + testobject = {'123': 456, '789': '456'} + buf = BytesIO() + json.dump(testobject, codecs.getwriter('utf-8')(buf)) + + buf.seek(0) + qro = QueryResultOption(lambda: buf) + self.assertEqual(testobject, qro.as_json()) + self.assertEqual(testobject, qro.as_json()) + + def test_text(self): + testobject = {'123': 456, '789': '456'} + buf = BytesIO() + json.dump(testobject, codecs.getwriter('utf-8')(buf)) + + buf.seek(0) + qro = QueryResultOption(lambda: buf) + self.assertEqual(json.dumps(testobject), qro.as_text()) + self.assertEqual(json.dumps(testobject), qro.as_text()) |