Add simple import test
authorGuido Günther <agx@sigxcpu.org>
Tue, 5 Jan 2016 17:18:55 +0000 (18:18 +0100)
committerGuido Günther <agx@sigxcpu.org>
Tue, 5 Jan 2016 17:18:55 +0000 (18:18 +0100)
vCard is from

    https://en.wikipedia.org/wiki/VCard#vCard_4.0

tests/__init__.py [new file with mode: 0644]
tests/data/import.vcard [new file with mode: 0644]
tests/test_collection.py [new file with mode: 0644]

diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/data/import.vcard b/tests/data/import.vcard
new file mode 100644 (file)
index 0000000..b9d2c5f
--- /dev/null
@@ -0,0 +1,17 @@
+BEGIN:VCARD
+VERSION:4.0
+N:Gump;Forrest;;;
+FN:Forrest Gump
+ORG:Bubba Gump Shrimp Co.
+TITLE:Shrimp Man
+PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
+TEL;TYPE=work,voice;VALUE=uri:tel:+11115551212
+TEL;TYPE=home,voice;VALUE=uri:tel:+14045551212
+ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States of A
+ merica":;;100 Waters Edge;Baytown;LA;30314;United States of America
+ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of
+ America":;;42 Plantation St.;Baytown;LA;30314;United States of America
+EMAIL:forrestgump@example.com
+REV:20080424T195243Z
+END:VCARD
+
diff --git a/tests/test_collection.py b/tests/test_collection.py
new file mode 100644 (file)
index 0000000..8e80faf
--- /dev/null
@@ -0,0 +1,29 @@
+# vim: set fileencoding=utf-8 :
+"""Test L{gbp.command_wrappers.Command}'s tarball unpack"""
+
+import os
+import subprocess
+import tempfile
+import shutil
+import unittest
+
+import calypso.config
+from calypso.webdav import Collection
+
+
+class TestCollection(unittest.TestCase):
+    test_vcard = "tests/data/import.vcard"
+
+    def setUp(self):
+        self.tmpdir = tempfile.mkdtemp()
+        calypso.config.set('storage', 'folder', self.tmpdir)
+        subprocess.call(["git", "init", self.tmpdir]),
+
+    def tearDown(self):
+        if self.tmpdir:
+            shutil.rmtree(self.tmpdir)
+
+    def test_import_file(self):
+        collection = Collection("")
+        self.assertTrue(collection.import_file(self.test_vcard))
+        self.assertEqual(len(collection.items), 1)