summaryrefslogtreecommitdiffstats
path: root/cnucnu/tests
diff options
context:
space:
mode:
authorTill Maas <opensource@till.name>2009-07-19 17:08:24 +0200
committerTill Maas <opensource@till.name>2009-07-19 17:08:24 +0200
commitce1383726feefa1e0f8aa53b4803f36733726611 (patch)
treef1c675b5d3bf6441b136f6dc74e695c36880332c /cnucnu/tests
parentc6c86d92cc56628a86d566a838940a7c062252b0 (diff)
downloadcnucnu-ce1383726feefa1e0f8aa53b4803f36733726611.tar.gz
cnucnu-ce1383726feefa1e0f8aa53b4803f36733726611.tar.xz
cnucnu-ce1383726feefa1e0f8aa53b4803f36733726611.zip
remove dir lib for saner imports(?)
Diffstat (limited to 'cnucnu/tests')
-rw-r--r--cnucnu/tests/__init__.py0
-rwxr-xr-xcnucnu/tests/config_test.py57
-rwxr-xr-xcnucnu/tests/mail_test.py49
-rwxr-xr-xcnucnu/tests/package_list_test.py58
4 files changed, 164 insertions, 0 deletions
diff --git a/cnucnu/tests/__init__.py b/cnucnu/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cnucnu/tests/__init__.py
diff --git a/cnucnu/tests/config_test.py b/cnucnu/tests/config_test.py
new file mode 100755
index 0000000..afa576b
--- /dev/null
+++ b/cnucnu/tests/config_test.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# vim: fileencoding=utf8 foldmethod=marker
+#{{{ License header: GPLv2+
+# This file is part of cnucnu.
+#
+# Cnucnu is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Cnucnu is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cnucnu. If not, see <http://www.gnu.org/licenses/>.
+#}}}
+
+import unittest
+
+import sys
+sys.path.insert(0, '../..')
+
+from cnucnu.config import Config
+
+class ConfigTest(unittest.TestCase):
+
+ def testCreateConfig(self):
+ c = Config()
+ c = Config(yaml="{}")
+ c = Config(config={})
+
+ def testSimpleUpdate(self):
+ old = {0: 0, "d": {0: 0}}
+ new = {1: 1, "d": {1: 1}}
+ expected = {0: 0, 1: 1, "d": {0: 0, 1: 1}}
+
+ c = Config(config=old, load_default=False)
+ c.update(new)
+
+ self.assertEqual(c.config, expected)
+
+ def testComplexUpdate(self):
+ old = {0: 0, "d": {0: 0, 1: 1, 2: 2}, 2: {}}
+ new = {1: 1, "d": {1: {0: 0}, 2: None}}
+ expected = {0: 0, 1: 1, "d": {0: 0, 1: {0: 0}, 2: None}, 2: {}}
+
+ c = Config(config=old, load_default=False)
+ c.update(new)
+
+ self.assertEqual(c.config, expected)
+
+if __name__ == "__main__":
+ suite = unittest.TestLoader().loadTestsFromTestCase(ConfigTest)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+ #unittest.main()
diff --git a/cnucnu/tests/mail_test.py b/cnucnu/tests/mail_test.py
new file mode 100755
index 0000000..0be8d23
--- /dev/null
+++ b/cnucnu/tests/mail_test.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# vim: fileencoding=utf8 foldmethod=marker
+#{{{ License header: GPLv2+
+# This file is part of cnucnu.
+#
+# Cnucnu is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Cnucnu is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cnucnu. If not, see <http://www.gnu.org/licenses/>.
+#}}}
+
+import unittest
+
+import sys
+sys.path.insert(0, '../..')
+
+
+from cnucnu.mail import Message
+
+class MailTest(unittest.TestCase):
+
+ def testCreateMessage(self):
+ m = Message("me@example.com", "you@example.com", "subject", "message")
+
+ def testMessageEncoding(self):
+ sender = "Mr. Umläut <u@example.com>"
+ receipient = "ß <l@example.com>"
+ subject = "ä"
+ message = "Ö"
+
+ m = Message(sender, receipient, subject, message)
+ self.assertEqual(m.receipient, receipient)
+ self.assertEqual(m.sender, sender)
+ message_string = 'MIME-Version: 1.0\nContent-Type: text/plain; charset="utf-8"\nContent-Transfer-Encoding: base64\nSubject: =?utf-8?b?w6Q=?=\nFrom: =?utf-8?b?TXIuIFVtbMOkdXQ=?= <u@example.com>\nTo: =?utf-8?b?w58=?= <l@example.com>\n\nw5Y=\n'
+ self.assertEqual(message_string, m.as_string())
+
+
+if __name__ == "__main__":
+ suite = unittest.TestLoader().loadTestsFromTestCase(MailTest)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+ #unittest.main()
diff --git a/cnucnu/tests/package_list_test.py b/cnucnu/tests/package_list_test.py
new file mode 100755
index 0000000..20388e3
--- /dev/null
+++ b/cnucnu/tests/package_list_test.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+# vim: fileencoding=utf8 foldmethod=marker
+#{{{ License header: GPLv2+
+# This file is part of cnucnu.
+#
+# Cnucnu is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Cnucnu is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cnucnu. If not, see <http://www.gnu.org/licenses/>.
+#}}}
+
+import unittest
+
+import sys
+sys.path.insert(0, '../..')
+
+from cnucnu.package_list import Package
+from cnucnu.package_list import Repository
+
+class PackageTest(unittest.TestCase):
+
+ def testCreatePackage(self):
+ p = Package("name", "regex", "url", Repository())
+
+ def testRegexUpdate(self):
+ p = Package("name", "regex", "url", Repository())
+ p._upstream_versions = [0, 1]
+ p._latest_upstream = 1
+ p._rpm_diff = 0
+ p.regex = "new regex"
+ self.assertEqual(p.regex, "new regex")
+ self.assertEqual(p._upstream_versions, None)
+ self.assertEqual(p._latest_upstream, None)
+ self.assertEqual(p._rpm_diff, None)
+
+ def testUrlUpdate(self):
+ p = Package("name", "regex", "url", Repository())
+ p._upstream_versions = [0, 1]
+ p._latest_upstream = 1
+ p._rpm_diff = 1
+ p.url = "new url"
+ self.assertEqual(p.url, "new url")
+ self.assertEqual(p._upstream_versions, None)
+ self.assertEqual(p._latest_upstream, None)
+ self.assertEqual(p._rpm_diff, None)
+
+if __name__ == "__main__":
+ suite = unittest.TestLoader().loadTestsFromTestCase(PackageTest)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+ #unittest.main()