aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-16 19:22:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-16 19:22:00 +0100
commit0d7936544c872dd0d462f55fbd83deb06ea8bcc1 (patch)
treeecf757ced40b1bce872b5c92bef28ad8f1f47548
parentd9cb4485bc933d26e9fbc787a12c529a5f6b0b21 (diff)
downloadpaludis-0d7936544c872dd0d462f55fbd83deb06ea8bcc1.tar.gz
paludis-0d7936544c872dd0d462f55fbd83deb06ea8bcc1.tar.xz
Don't use NoConfigEnvironment for tests
-rw-r--r--python/choices_TEST.py8
-rwxr-xr-xpython/choices_TEST_setup.sh22
-rwxr-xr-xpython/environment_TEST.py25
-rwxr-xr-xpython/metadata_key_TEST.py11
-rwxr-xr-xpython/metadata_key_TEST_setup.sh31
-rwxr-xr-xpython/package_id_TEST.py7
-rwxr-xr-xpython/package_id_TEST_setup.sh31
-rwxr-xr-xpython/repository_TEST.py6
8 files changed, 102 insertions, 39 deletions
diff --git a/python/choices_TEST.py b/python/choices_TEST.py
index 7e9f947..e22b0a5 100644
--- a/python/choices_TEST.py
+++ b/python/choices_TEST.py
@@ -21,6 +21,8 @@
import os
repo_path = os.path.join(os.getcwd(), "choices_TEST_dir/testrepo")
+ph = os.path.join(os.getcwd(), "choices_TEST_dir/home")
+os.environ["PALUDIS_HOME"] = ph
from paludis import *
from additional_tests import *
@@ -31,7 +33,7 @@ Log.instance.log_level = LogLevel.WARNING
class TestCase_01_Choices(unittest.TestCase):
def setUp(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
+ self.e = EnvironmentFactory.instance.create("")
self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value()
@@ -57,7 +59,7 @@ class TestCase_01_Choices(unittest.TestCase):
class TestCase_02_Choice(unittest.TestCase):
def setUp(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
+ self.e = EnvironmentFactory.instance.create("")
self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value()
self.use = None
@@ -106,7 +108,7 @@ class TestCase_02_Choice(unittest.TestCase):
class TestCase_03_ChoiceValue(unittest.TestCase):
def setUp(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
+ self.e = EnvironmentFactory.instance.create("")
self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value()
self.use_testflag = self.choices.find_by_name_with_prefix("testflag")
diff --git a/python/choices_TEST_setup.sh b/python/choices_TEST_setup.sh
index 9a8b5b8..8f1b94c 100755
--- a/python/choices_TEST_setup.sh
+++ b/python/choices_TEST_setup.sh
@@ -4,6 +4,28 @@
mkdir choices_TEST_dir || exit 1
cd choices_TEST_dir || exit 1
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
+cat <<END > home/.paludis/keywords.conf
+*/* test
+END
+cat <<END > home/.paludis/licenses.conf
+*/* *
+END
+
+cat <<END > home/.paludis/general.conf
+world = /dev/null
+END
+
mkdir -p testrepo/{eclass,distfiles,profiles/{testprofile,desc},foo/bar/files} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
diff --git a/python/environment_TEST.py b/python/environment_TEST.py
index c81b01f..860a682 100755
--- a/python/environment_TEST.py
+++ b/python/environment_TEST.py
@@ -35,41 +35,18 @@ Log.instance.log_level = LogLevel.WARNING
class TestCase_01_Environments(unittest.TestCase):
def setUp(self):
self.e = EnvironmentFactory.instance.create("")
- self.nce = NoConfigEnvironment(repo)
-
- def test_01_create(self):
- NoConfigEnvironment(repo)
- NoConfigEnvironment(repo, "/var/empty")
- NoConfigEnvironment(repo, "/var/empty", "")
- NoConfigEnvironment(repo, master_repository_name="")
- NoConfigEnvironment(repo, write_cache_dir="/var/empty")
def test_02_create_error(self):
self.assertRaises(Exception, Environment)
- self.assertRaises(Exception, NoConfigEnvironment)
-
- def test_03_subclass(self):
- self.assert_(isinstance(NoConfigEnvironment(repo), Environment))
def test_07_sets(self):
self.assert_(isinstance(self.e.set("everything"), AllDepSpec))
- self.assert_(isinstance(self.nce.set("everything"), AllDepSpec))
-
self.assert_(isinstance(self.e.set_names, SetNameIterable))
- self.assert_(isinstance(self.nce.set_names, SetNameIterable))
-
- def test_08_repositories(self):
- nce2 = NoConfigEnvironment(repo, master_repository_name="slaverepo", extra_repository_dirs=[slaverepo])
-
- self.assert_(isinstance(self.nce.main_repository, Repository))
- self.assertEquals(self.nce.master_repository, None)
- self.assert_(isinstance(nce2.main_repository, Repository))
- self.assert_(isinstance(nce2.master_repository, Repository))
def test_12_config_dir(self):
self.assert_(isinstance(self.e.config_dir, str))
- def test_23_fech_unique_qpn(self):
+ def test_23_fetch_unique_qpn(self):
self.assertEqual(str(QualifiedPackageName("foo/bar")), str(self.e.fetch_unique_qualified_package_name("bar")))
self.assertEqual(str(QualifiedPackageName("foo/bar")), str(self.e.fetch_unique_qualified_package_name("bar",
Filter.SupportsInstallAction())))
diff --git a/python/metadata_key_TEST.py b/python/metadata_key_TEST.py
index 776fdc6..a8ab381 100755
--- a/python/metadata_key_TEST.py
+++ b/python/metadata_key_TEST.py
@@ -22,6 +22,8 @@ import os
repo_path = os.path.join(os.getcwd(), "metadata_key_TEST_dir/testrepo")
irepo_path = os.path.join(os.getcwd(), "metadata_key_TEST_dir/installed")
+ph = os.path.join(os.getcwd(), "metadata_key_TEST_dir/home")
+os.environ["PALUDIS_HOME"] = ph
from paludis import *
from additional_tests import *
@@ -32,10 +34,9 @@ Log.instance.log_level = LogLevel.WARNING
class TestCase_01_MetadataKeys(unittest.TestCase):
def setUp(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
- self.ie = NoConfigEnvironment(irepo_path)
+ self.e = EnvironmentFactory.instance.create("")
self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
- self.ipid = iter(self.ie.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next()
+ self.ipid = iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next()
def test_01_contents(self):
self.assertEquals(self.pid.find_metadata("CONTENTS"), None)
@@ -72,7 +73,7 @@ class TestCase_02_MetadataKeys_suclassing(unittest.TestCase):
MetadataPackageIDKey.__init__(self)
def parse_value(self):
- e = NoConfigEnvironment(repo_path, "/var/empty")
+ e = EnvironmentFactory.instance.create("")
pid = iter(e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
return pid
@@ -222,7 +223,7 @@ class TestCase_02_MetadataKeys_suclassing(unittest.TestCase):
def test_12_dependency_spec_tree(self):
class TestKey(MetadataDependencySpecTreeKey):
def __init__(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
+ self.e = EnvironmentFactory.instance.create("")
MetadataDependencySpecTreeKey.__init__(self)
def parse_value(self):
diff --git a/python/metadata_key_TEST_setup.sh b/python/metadata_key_TEST_setup.sh
index 8616e49..ee12c5f 100755
--- a/python/metadata_key_TEST_setup.sh
+++ b/python/metadata_key_TEST_setup.sh
@@ -4,6 +4,37 @@
mkdir metadata_key_TEST_dir || exit 1
cd metadata_key_TEST_dir || exit 1
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+cache = /var/empty
+builddir = `pwd`
+name = installed
+END
+
+cat <<END > home/.paludis/keywords.conf
+*/* test
+END
+cat <<END > home/.paludis/licenses.conf
+*/* *
+END
+
+cat <<END > home/.paludis/general.conf
+world = /dev/null
+END
+
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index 51c6cf9..bd821e7 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -22,6 +22,8 @@ import os
repo_path = os.path.join(os.getcwd(), "package_id_TEST_dir/testrepo")
irepo_path = os.path.join(os.getcwd(), "package_id_TEST_dir/installed")
+ph = os.path.join(os.getcwd(), "package_id_TEST_dir/home")
+os.environ["PALUDIS_HOME"] = ph
from paludis import *
import unittest
@@ -30,10 +32,9 @@ Log.instance.log_level = LogLevel.WARNING
class TestCase_01_PackageID(unittest.TestCase):
def setUp(self):
- self.e = NoConfigEnvironment(repo_path, "/var/empty")
- self.ie = NoConfigEnvironment(irepo_path)
+ self.e = EnvironmentFactory.instance.create("")
self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next()
- self.ipid = iter(self.ie.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next()
+ self.ipid = iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next()
self.mpid = iter(self.e.fetch_repository("testrepo").package_ids("cat/masked", [])).next()
def test_01_get(self):
diff --git a/python/package_id_TEST_setup.sh b/python/package_id_TEST_setup.sh
index 0efc5ff..01b9141 100755
--- a/python/package_id_TEST_setup.sh
+++ b/python/package_id_TEST_setup.sh
@@ -4,6 +4,37 @@
mkdir package_id_TEST_dir || exit 1
cd package_id_TEST_dir || exit 1
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+cache = /var/empty
+builddir = `pwd`
+name = installed
+END
+
+cat <<END > home/.paludis/keywords.conf
+*/* test
+END
+cat <<END > home/.paludis/licenses.conf
+*/* *
+END
+
+cat <<END > home/.paludis/general.conf
+world = /dev/null
+END
+
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar,cat/masked} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index 4cb9d3b..10b1e68 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -34,9 +34,8 @@ Log.instance.log_level = LogLevel.WARNING
class TestCase_01_Repository(unittest.TestCase):
def setUp(self):
- global e, nce, repo, irepo
+ global e, repo, irepo
e = EnvironmentFactory.instance.create("")
- nce = NoConfigEnvironment(repo_path)
repo = e.fetch_repository("testrepo")
irepo = e.fetch_repository("installed")
@@ -100,9 +99,8 @@ class TestCase_01_Repository(unittest.TestCase):
class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def setUp(self):
- global e, nce, repo, irepo
+ global e, repo, irepo
e = EnvironmentFactory.instance.create("")
- nce = NoConfigEnvironment(repo_path)
repo = e.fetch_repository("testrepo")
irepo = e.fetch_repository("installed")