aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-22 02:01:04 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-22 02:01:04 -0300
commit54cc6725b2c8780d8ef5ddbf5d244a5227fa83d5 (patch)
treef22c03cb8459a64e72b37bac7dc17164551d00b3 /tests
parentadded missing '-' at scripts/run_tests.py (diff)
downloadg-octave-54cc6725b2c8780d8ef5ddbf5d244a5227fa83d5.tar.gz
g-octave-54cc6725b2c8780d8ef5ddbf5d244a5227fa83d5.tar.bz2
g-octave-54cc6725b2c8780d8ef5ddbf5d244a5227fa83d5.zip
small fixes at g_octave/description.py; added tests/test_description.py (not complete)
Diffstat (limited to 'tests')
-rw-r--r--tests/DESCRIPTION20
-rw-r--r--tests/test_description.py119
2 files changed, 139 insertions, 0 deletions
diff --git a/tests/DESCRIPTION b/tests/DESCRIPTION
new file mode 100644
index 0000000..7d7b186
--- /dev/null
+++ b/tests/DESCRIPTION
@@ -0,0 +1,20 @@
+Name: package name
+Version: 0.0.1
+Date: 2009-01-01
+Author: Author Name
+Maintainer: Maintainer Name
+Title: Package Title
+Description: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
+ ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
+ in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
+ mollit anim id est laborum.
+Categories: Category1,Category2, Category3
+Url: http://example.org
+SystemRequirements: pkg1 ( >= 4.3.2), pkg2 (<1.2.3 ), pkg3
+BuildRequires: pkg4 (>1.0.0)
+Depends: Octave ( >= 3.0.0 )
+Autoload: NO
+License: GPL version 3 or later
diff --git a/tests/test_description.py b/tests/test_description.py
new file mode 100644
index 0000000..a549ef5
--- /dev/null
+++ b/tests/test_description.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ test_description.py
+ ~~~~~~~~~~~~~~~~~~~
+
+ test suite for the *g_octave.description* module
+
+ :copyright: (c) 2010 by Rafael Goncalves Martins
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os
+import unittest
+
+from g_octave import description
+
+
+class TestDescription(unittest.TestCase):
+
+ def setUp(self):
+ self.desc = description.Description(
+ os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), 'DESCRIPTION'
+ )
+ )
+
+ def test_re_depends(self):
+ depends = [
+ ('pkg', ('pkg', None, None)),
+ ('pkg(<1)', ('pkg', '<', '1')),
+ ('pkg(>1)', ('pkg', '>', '1')),
+ ('pkg(<=1)', ('pkg', '<=', '1')),
+ ('pkg(>=1)', ('pkg', '>=', '1')),
+ ('pkg(==1)', ('pkg', '==', '1')),
+ ('pkg( <1)', ('pkg', '<', '1')),
+ ('pkg( >1)', ('pkg', '>', '1')),
+ ('pkg( <=1)', ('pkg', '<=', '1')),
+ ('pkg( >=1)', ('pkg', '>=', '1')),
+ ('pkg( ==1)', ('pkg', '==', '1')),
+ ('pkg(<1 )', ('pkg', '<', '1')),
+ ('pkg(>1 )', ('pkg', '>', '1')),
+ ('pkg(<=1 )', ('pkg', '<=', '1')),
+ ('pkg(>=1 )', ('pkg', '>=', '1')),
+ ('pkg(==1 )', ('pkg', '==', '1')),
+ ('pkg( <1 )', ('pkg', '<', '1')),
+ ('pkg( >1 )', ('pkg', '>', '1')),
+ ('pkg( <=1 )', ('pkg', '<=', '1')),
+ ('pkg( >=1 )', ('pkg', '>=', '1')),
+ ('pkg( ==1 )', ('pkg', '==', '1')),
+ ('pkg(<1.0)', ('pkg', '<', '1.0')),
+ ('pkg(>1.0)', ('pkg', '>', '1.0')),
+ ('pkg(<=1.0)', ('pkg', '<=', '1.0')),
+ ('pkg(>=1.0)', ('pkg', '>=', '1.0')),
+ ('pkg(==1.0)', ('pkg', '==', '1.0')),
+ ('pkg( <1.0)', ('pkg', '<', '1.0')),
+ ('pkg( >1.0)', ('pkg', '>', '1.0')),
+ ('pkg( <=1.0)', ('pkg', '<=', '1.0')),
+ ('pkg( >=1.0)', ('pkg', '>=', '1.0')),
+ ('pkg( ==1.0)', ('pkg', '==', '1.0')),
+ ('pkg(<1.0 )', ('pkg', '<', '1.0')),
+ ('pkg(>1.0 )', ('pkg', '>', '1.0')),
+ ('pkg(<=1.0 )', ('pkg', '<=', '1.0')),
+ ('pkg(>=1.0 )', ('pkg', '>=', '1.0')),
+ ('pkg(==1.0 )', ('pkg', '==', '1.0')),
+ ('pkg( <1.0 )', ('pkg', '<', '1.0')),
+ ('pkg( >1.0 )', ('pkg', '>', '1.0')),
+ ('pkg( <=1.0 )', ('pkg', '<=', '1.0')),
+ ('pkg( >=1.0 )', ('pkg', '>=', '1.0')),
+ ('pkg( ==1.0 )', ('pkg', '==', '1.0')),
+ ('pkg(<1.0.0)', ('pkg', '<', '1.0.0')),
+ ('pkg(>1.0.0)', ('pkg', '>', '1.0.0')),
+ ('pkg(<=1.0.0)', ('pkg', '<=', '1.0.0')),
+ ('pkg(>=1.0.0)', ('pkg', '>=', '1.0.0')),
+ ('pkg(==1.0.0)', ('pkg', '==', '1.0.0')),
+ ('pkg( <1.0.0)', ('pkg', '<', '1.0.0')),
+ ('pkg( >1.0.0)', ('pkg', '>', '1.0.0')),
+ ('pkg( <=1.0.0)', ('pkg', '<=', '1.0.0')),
+ ('pkg( >=1.0.0)', ('pkg', '>=', '1.0.0')),
+ ('pkg( ==1.0.0)', ('pkg', '==', '1.0.0')),
+ ('pkg(<1.0.0 )', ('pkg', '<', '1.0.0')),
+ ('pkg(>1.0.0 )', ('pkg', '>', '1.0.0')),
+ ('pkg(<=1.0.0 )', ('pkg', '<=', '1.0.0')),
+ ('pkg(>=1.0.0 )', ('pkg', '>=', '1.0.0')),
+ ('pkg(==1.0.0 )', ('pkg', '==', '1.0.0')),
+ ('pkg( <1.0.0 )', ('pkg', '<', '1.0.0')),
+ ('pkg( >1.0.0 )', ('pkg', '>', '1.0.0')),
+ ('pkg( <=1.0.0 )', ('pkg', '<=', '1.0.0')),
+ ('pkg( >=1.0.0 )', ('pkg', '>=', '1.0.0')),
+ ('pkg( ==1.0.0 )', ('pkg', '==', '1.0.0')),
+ ]
+ for pkgstr, pkgtpl in depends:
+ match = description.re_depends.match(pkgstr)
+ self.assertEqual(
+ (match.group(1), match.group(3), match.group(4)),
+ pkgtpl
+ )
+
+ def test_re_pkg_atom(self):
+ depends = [
+ ('pkg-1', ('pkg', '1')),
+ ('pkg-1.0', ('pkg', '1.0')),
+ ('pkg-1.0.0', ('pkg', '1.0.0')),
+ ]
+ for pkgstr, pkgtpl in depends:
+ match = description.re_pkg_atom.match(pkgstr)
+ self.assertEqual(
+ (match.group(1), match.group(2)),
+ pkgtpl
+ )
+
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(TestDescription('test_re_depends'))
+ suite.addTest(TestDescription('test_re_pkg_atom'))
+ return suite
+