[conduit: 113/138] Add text, setting, bookmark and email datatype wrappers
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 113/138] Add text, setting, bookmark and email datatype wrappers
- Date: Thu, 21 May 2009 03:36:24 -0400 (EDT)
commit 01c33037a0161c815a6eac62148b52f70db6ce4f
Author: John Carr <john carr unrouted co uk>
Date: Wed May 6 06:02:13 2009 -0700
Add text, setting, bookmark and email datatype wrappers
---
test/soup/data/bookmark.py | 22 ++++++++++++++++++++++
test/soup/data/email.py | 22 ++++++++++++++++++++++
test/soup/data/setting.py | 21 +++++++++++++++++++++
test/soup/data/text.py | 24 ++++++++++++++++++++++++
4 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/test/soup/data/bookmark.py b/test/soup/data/bookmark.py
new file mode 100644
index 0000000..6bdb738
--- /dev/null
+++ b/test/soup/data/bookmark.py
@@ -0,0 +1,22 @@
+import soup
+
+import conduit.utils as Utils
+from conduit.datatypes import Bookmark
+
+import datetime
+
+class BookmarkWrapper(soup.data.DataWrapper):
+
+ wraps = Bookmark.Bookmark
+
+ def iter_samples(self):
+ #FIXME: Would be nice to have some actual bookmarks. Maybe awkward ones
+ # - unicode, ip addresses, weird encodings (%2F) etc
+ for i in range(5):
+ yield self.generate_sample()
+
+ def generate_sample(self):
+ b = Bookmark.Bookmark(title=Utils.random_string(), uri="http://%s.com/" % Utils.random_string())
+ b.set_mtime(datetime.datetime.now())
+ b.set_UID(b.get_uri())
+ return b
diff --git a/test/soup/data/email.py b/test/soup/data/email.py
new file mode 100644
index 0000000..1ac0946
--- /dev/null
+++ b/test/soup/data/email.py
@@ -0,0 +1,22 @@
+import soup
+
+import conduit.utils as Utils
+from conduit.datatypes import Email
+
+import datetime
+
+class EmailWrapper(soup.data.DataWrapper):
+
+ wraps = Email.Email
+
+ def iter_samples(self):
+ #FIXME: Would be nice to have some actual settings.
+ for i in range(5):
+ yield self.generate_sample()
+
+ def generate_sample(self):
+ e = Email.Email(content=Utils.random_string(), subject=Utils.random_string())
+ e.set_mtime(datetime.datetime.now())
+ e.set_UID(Utils.random_string())
+ return e
+
diff --git a/test/soup/data/setting.py b/test/soup/data/setting.py
new file mode 100644
index 0000000..cdde6bb
--- /dev/null
+++ b/test/soup/data/setting.py
@@ -0,0 +1,21 @@
+import soup
+
+import conduit.utils as Utils
+from conduit.datatypes import Setting
+
+import datetime
+
+class SettingWrapper(soup.data.DataWrapper):
+
+ wraps = Setting.Setting
+
+ def iter_samples(self):
+ #FIXME: Would be nice to have some actual settings.
+ for i in range(5):
+ yield self.generate_sample()
+
+ def generate_sample(self):
+ s = Setting.Setting(key=Utils.random_string(), value=Utils.random_string())
+ s.set_mtime(datetime.datetime.now())
+ s.set_UID(Utils.random_string())
+ return s
diff --git a/test/soup/data/text.py b/test/soup/data/text.py
new file mode 100644
index 0000000..0129132
--- /dev/null
+++ b/test/soup/data/text.py
@@ -0,0 +1,24 @@
+import soup
+
+import conduit.utils as Utils
+from conduit.datatypes import Text
+
+import datetime
+
+class TextWrapper(soup.data.DataWrapper):
+
+ wraps = Text.Text
+
+ def iter_samples(self):
+ #FIXME: This is not very useful
+ for f in self.get_files_from_data_dir("*.ical"):
+ t = Text.Text(text=open(f).read())
+ t.set_mtime(datetime.datetime.now())
+ t.set_UID(Utils.random_string())
+ yield t
+
+ def generate_sample(self):
+ t = Text.Text(text=Utils.random_string())
+ t.set_mtime(datetime.datetime.now())
+ t.set_UID(Utils.random_string())
+ return t
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]