From: Oleg Broytman Date: Wed, 6 Apr 2016 19:50:10 +0000 (+0300) Subject: Add tests for importing INPX files X-Git-Tag: 0.0.4~23 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=d31c0e3f3f33c7b99cd972d0761f2744de068f1f;p=m_librarian.git Add tests for importing INPX files --- diff --git a/tests/bad.inpx b/tests/bad.inpx new file mode 100644 index 0000000..d54c57e Binary files /dev/null and b/tests/bad.inpx differ diff --git a/tests/test.inpx b/tests/test.inpx new file mode 100644 index 0000000..f794270 Binary files /dev/null and b/tests/test.inpx differ diff --git a/tests/test_inp.py b/tests/test_inp.py new file mode 100755 index 0000000..ff3cfa4 --- /dev/null +++ b/tests/test_inp.py @@ -0,0 +1,23 @@ +#! /usr/bin/env python + + +import os +from tests import TestCase, main +from m_librarian.db import Author, Book +from m_librarian.inp import import_inpx + + +class TestInp(TestCase): + def test_import_bad_inpx(self): + self.assertRaises( + ValueError, import_inpx, + os.path.join(os.path.dirname(__file__), 'bad.inpx')) + + def test_import_inpx(self): + import_inpx(os.path.join(os.path.dirname(__file__), 'test.inpx')) + self.assertEqual(Author.select().count(), 4) + self.assertEqual(Book.select().count(), 4) + + +if __name__ == "__main__": + main()