[packagekit] [PATCH 5/5] conary: add some test
Jesse Zhang
zh.jesse at gmail.com
Sat Jan 29 03:59:45 PST 2011
---
backends/conary/test-label.xml | 28 +++++++++++++++++++++++++++
backends/conary/test.py | 41 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
create mode 100644 backends/conary/test-label.xml
create mode 100755 backends/conary/test.py
diff --git a/backends/conary/test-label.xml b/backends/conary/test-label.xml
new file mode 100644
index 0000000..5b65bba
--- /dev/null
+++ b/backends/conary/test-label.xml
@@ -0,0 +1,28 @@
+<Packages label="test-label">
+
+<Package>
+ <name>kernel</name>
+ <version>2.6.35.10-5-1</version>
+ <shortDesc lang="en">The Linux kernel</shortDesc>
+ <longDesc lang="en">
+ The kernel package contains the Linux kernel (vmlinuz), the core of any Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc.
+ </longDesc>
+</Package>
+
+<Package>
+ <name>splint</name>
+ <version>3.1.1-7-0.1</version>
+ <crypto lang="en">['None']</crypto>
+ <licenses lang="en">['rpath.com/licenses/copyright/GPL-2']</licenses>
+</Package>
+
+<Package>
+ <name>xchat</name>
+ <version>2.8.8-1-1</version>
+ <shortDesc lang="en">XChat IRC</shortDesc>
+ <longDesc lang="en">Chat with other people using Internet Relay Chat</longDesc>
+ <category lang="en">Application</category>
+ <category lang="en">Network</category>
+</Package>
+
+</Packages>
diff --git a/backends/conary/test.py b/backends/conary/test.py
new file mode 100755
index 0000000..ac8f701
--- /dev/null
+++ b/backends/conary/test.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+import unittest
+import os
+
+import XMLCache
+
+class TestXMLRepo(unittest.TestCase):
+ def setUp(self):
+ test_label = 'test-label'
+ self.xml_repo = XMLCache.XMLRepo(label=test_label, path=os.getcwd(), pk=None)
+
+ def test_search_name_count(self):
+ self.assertEqual(1, len(self.xml_repo.search(['kernel'], 'name')))
+
+ def test_search_name_count2(self):
+ self.assertEqual(1, len(self.xml_repo.search(['kernel', 'kernel'], 'name')))
+
+ def test_search_name_name(self):
+ self.assertEqual('kernel',
+ self.xml_repo.search(['kernel'], 'name')[0]['name'])
+
+ def test_search_name_url(self):
+ self.assertEqual('',
+ self.xml_repo.search(['kernel'], 'name')[0]['url'])
+
+ def test_search_detail_count(self):
+ self.assertEqual(1, len(self.xml_repo.search(['xchat'], 'details')))
+
+ def test_search_detail_version(self):
+ self.assertEqual('2.8.8-1-1',
+ self.xml_repo.search(['xchat'], 'details')[0]['version'])
+
+ def test_search_group_count(self):
+ self.assertEqual(1, len(self.xml_repo.search(['internet'], 'group')))
+
+ def test_search_group_count2(self):
+ self.assertEqual(1, len(self.xml_repo.search(['internet', 'internet'], 'group')))
+
+if __name__ == '__main__':
+ unittest.main()
--
1.7.3.4
More information about the PackageKit
mailing list