From 19119e3eefe43d285f3baf95a3a023113e23ac79 Mon Sep 17 00:00:00 2001 From: Lingchao Xin Date: Fri, 29 Nov 2013 11:16:11 +0800 Subject: [PATCH] Add testcases Change-Id: I668c9a59fbd3fec6364439f0a92c90c531804a26 --- .gitignore | 51 +++++++++++++++++++++++++++++++++ snapdiff/templates/sparrow.html | 6 ++++ tests/test_render.py | 16 +++++++++++ tests/test_utils.py | 38 ++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 snapdiff/templates/sparrow.html create mode 100644 tests/test_render.py create mode 100644 tests/test_utils.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..50a8726 --- /dev/null +++ b/.gitignore @@ -0,0 +1,51 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +# Sphinx documentation +docs/_build/ + diff --git a/snapdiff/templates/sparrow.html b/snapdiff/templates/sparrow.html new file mode 100644 index 0000000..1c01047 --- /dev/null +++ b/snapdiff/templates/sparrow.html @@ -0,0 +1,6 @@ + + diff --git a/tests/test_render.py b/tests/test_render.py new file mode 100644 index 0000000..099f0ff --- /dev/null +++ b/tests/test_render.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +"""Tests for render module.""" + +import unittest +from snapdiff import render + + +class RenderTestCase(unittest.TestCase): + + def test_output_html(self): + """Ensures that we can properly render html pages""" + users = [{'url': 'http://example.com', 'username': 'foo'}] + output = render.output_html('sparrow.html', users=users) + self.assertEqual(output, u'\n') + diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..48e5982 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,38 @@ +"""Tests for utils module.""" + +import unittest +from snapdiff import utils + + +class UtilsTestCase(unittest.TestCase): + + _multiprocess_can_split_ = True + + def test_xml2obj(self): + """Ensures that we can properly parse xml to python objs""" + repomd = """ + + 1385428310 + + + 06d90b19c6c1677b8ab3f7 + 1385428316.34 + 251882 + 952320 + 71428390a3e9423abb + 10 + + + + df569d7923ed3f60943449 + 1385428350.75 + aab93a15ded699ffd46 + + + """ + + obj = utils.xml2obj(repomd) + self.assertEqual(obj.revision, '1385428310') + self.assertTrue(isinstance(obj['data'], list)) + self.assertEqual(obj['data'][0].size, '251882') + -- 2.34.1