]> git.phdru.name Git - m_librarian.git/commitdiff
Add tests for importing INPX files
authorOleg Broytman <phd@phdru.name>
Wed, 6 Apr 2016 19:50:10 +0000 (22:50 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 6 Apr 2016 19:50:10 +0000 (22:50 +0300)
tests/bad.inpx [new file with mode: 0644]
tests/test.inpx [new file with mode: 0644]
tests/test_inp.py [new file with mode: 0755]

diff --git a/tests/bad.inpx b/tests/bad.inpx
new file mode 100644 (file)
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 (file)
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 (executable)
index 0000000..ff3cfa4
--- /dev/null
@@ -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()