From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: /, gentoopm/tests/
Date: Thu, 14 Jul 2011 22:51:02 +0000 (UTC) [thread overview]
Message-ID: <88cb9b5a3f27fec7bbdb5f07d101ac04dddeede5.mgorny@gentoo> (raw)
commit: 88cb9b5a3f27fec7bbdb5f07d101ac04dddeede5
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 22:50:10 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 22:50:10 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=88cb9b5a
Add tests for Atom class impl.
---
gentoopm/tests/atom.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++
setup.py | 1 +
2 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/gentoopm/tests/atom.py b/gentoopm/tests/atom.py
new file mode 100644
index 0000000..bee882d
--- /dev/null
+++ b/gentoopm/tests/atom.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from gentoopm.exceptions import InvalidAtomStringError, AmbiguousPackageSetError
+from gentoopm.tests import PMTestCase
+
+class UserSpecifiedAtomTestCase(PMTestCase):
+ def setUp(self):
+ self._incomplete_atom = self.pm.Atom('portage')
+ self._complete_atom = self.pm.Atom('sys-apps/portage')
+ self._associated_atom = self._complete_atom.get_associated(self.pm.stack)
+
+ def test_invalid_atoms(self):
+ for atstr in ('<>foo', '=bar', '*/*::baz'):
+ self.assertRaises(InvalidAtomStringError, self.pm.Atom, atstr)
+
+ def test_incomplete_atom(self):
+ a = self._incomplete_atom
+ self.assertEqual(a.complete, False)
+ self.assertEqual(a.associated, False)
+
+ def test_complete_atom(self):
+ a = self._complete_atom
+ self.assertEqual(a.complete, True)
+ self.assertEqual(a.associated, False)
+
+ def test_atom_stringification(self):
+ for atstr in ('foo/bar', '>=baz/bar-100', 'foo/baz:10',
+ 'bar/baz::foo', '>=foo/fooz-29.5:bazmania', '~baz/inga-4.1:2::foo'):
+ self.assertEqual(atstr, str(self.pm.Atom(atstr)))
+
+ def test_atom_association(self):
+ a = self._associated_atom
+ self.assertEqual(a.complete, True)
+ self.assertEqual(a.associated, True)
+
+ def test_incomplete_atom_association(self):
+ a = self._incomplete_atom.get_associated(self.pm.stack)
+ self.assertEqual(a.complete, True)
+ self.assertEqual(a.associated, True)
+
+ def test_ambiguous_atom_association(self):
+ # XXX: risky
+ ia = self.pm.Atom('pms')
+ self.assertRaises(AmbiguousPackageSetError, ia.get_associated,
+ self.pm.stack)
+
+ def test_atom_transformations(self):
+ a = self._associated_atom
+ cas = str(self._complete_atom)
+ self.assertEqual(str(a.slotted), '%s:0' % cas)
+ self.assertEqual(str(a.unversioned), cas)
+
+ def tearDown(self):
+ pass
diff --git a/setup.py b/setup.py
index ba0553b..92fc300 100755
--- a/setup.py
+++ b/setup.py
@@ -53,6 +53,7 @@ class TestCommand(Command):
l = gentoopm.tests.PMTestLoader(pm_inst)
testsuite = unittest.TestSuite()
+ testsuite.addTests(l.loadTestsFromModule('gentoopm.tests.atom'))
maintestsuite.addTests(testsuite)
r = unittest.TextTestRunner()
next reply other threads:[~2011-07-14 22:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-14 22:51 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-07-14 22:51 [gentoo-commits] proj/gentoopm:master commit in: /, gentoopm/tests/ Michał Górny
2011-07-15 9:52 Michał Górny
2011-07-15 9:52 Michał Górny
2011-07-15 9:52 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15 12:34 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88cb9b5a3f27fec7bbdb5f07d101ac04dddeede5.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox