# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1468938324 -28800
# Node ID b55a7bba94ecc4113f5c56d83b26eb2ca78162b0
# Parent  7d1baf2f0b87e0855e2f032cf492f75e2534c046
tests: test status badge

diff -r 7d1baf2f0b87 -r b55a7bba94ec tests/test_viewer.py
--- a/tests/test_viewer.py	Tue Jul 19 22:22:48 2016 +0800
+++ b/tests/test_viewer.py	Tue Jul 19 22:25:24 2016 +0800
@@ -1,4 +1,5 @@
 from datetime import datetime
+from xml.etree import ElementTree
 
 from pytest import raises
 from tornado.web import HTTPError
@@ -61,3 +62,18 @@
         response = self.fetch('/nobodyhere')
         assert response.code == 404
         assert 'online linter' in response.body
+
+    def test_status(self):
+        response = self.fetch('/butt.cloud/cyber/wizard-attack/status.svg')
+        assert response.code == 404
+        assert 'online linter' in response.body
+
+        response = self.fetch('/example.com/alice/test-viewer/status.svg')
+        assert response.code == 200
+        root = ElementTree.fromstring(response.body)
+        ns = {'svg': 'http://www.w3.org/2000/svg'}
+        assert root.tag == '{http://www.w3.org/2000/svg}svg'
+        assert 'height' in root.attrib
+        assert root.attrib['height'] == '20'
+        text = [el.text for el in root.findall('./svg:g/svg:text', ns)]
+        assert text[::2] == ['lint', '1 error', '1 warning']