[Calypso] [PATCH 2/2] Add simple import test

Guido G√ľnther agx at sigxcpu.org
Sat Jan 2 08:10:46 PST 2016


vCard is from

    https://en.wikipedia.org/wiki/VCard#vCard_4.0
---
 tests/__init__.py        |  0
 tests/data/import.vcard  | 17 +++++++++++++++++
 tests/test_collection.py | 29 +++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 tests/__init__.py
 create mode 100644 tests/data/import.vcard
 create mode 100644 tests/test_collection.py

diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/data/import.vcard b/tests/data/import.vcard
new file mode 100644
index 0000000..57cb226
--- /dev/null
+++ b/tests/data/import.vcard
@@ -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 at example.com
+REV:20080424T195243Z
+END:VCARD
+
diff --git a/tests/test_collection.py b/tests/test_collection.py
new file mode 100644
index 0000000..6c6a56f
--- /dev/null
+++ b/tests/test_collection.py
@@ -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)
-- 
2.6.4



More information about the Calypso mailing list