aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMykyta Holubakha <hilobakho@gmail.com>2017-06-03 01:44:37 +0300
committerMykyta Holubakha <hilobakho@gmail.com>2017-06-03 01:44:37 +0300
commitfbe44d129c8a3dc2281012f6cc881c86f8809437 (patch)
treef00b2c1f68ec8a75d671d441d025ad330f841e26 /tests
parentSeparate active pomu repo detection (diff)
downloadpomu-fbe44d129c8a3dc2281012f6cc881c86f8809437.tar.gz
pomu-fbe44d129c8a3dc2281012f6cc881c86f8809437.tar.bz2
pomu-fbe44d129c8a3dc2281012f6cc881c86f8809437.zip
Test portage repo initialization
Diffstat (limited to 'tests')
-rw-r--r--tests/test_init.py47
1 files changed, 37 insertions, 10 deletions
diff --git a/tests/test_init.py b/tests/test_init.py
index 14c288a..651277f 100644
--- a/tests/test_init.py
+++ b/tests/test_init.py
@@ -1,25 +1,52 @@
-from os import makedirs
+import importlib
+import os
from shutil import rmtree
import unittest
+import portage
+
from pomu.repo.init import init_plain_repo, init_pomu
-from pomu.repo.repo import pomu_status
+from pomu.repo.repo import pomu_status, portage_repos
from pomu.util.result import Result
-REPO_PATH = 'test_repo'
+REPO_DIR = 'test_repo'
+REPO_PATH = os.path.join(os.getcwd(), REPO_DIR)
-class RepoInitialization(unittest.TestCase):
+class PlainRepoInitialization(unittest.TestCase):
def setUp(self):
- self.REPO_PATH = REPO_PATH
+ self.REPO_DIR = REPO_DIR
def tearDown(self):
- rmtree(self.REPO_PATH)
+ rmtree(self.REPO_DIR)
def testPlainInitializationAndStatus(self):
- init_plain_repo(True, self.REPO_PATH).expect()
- self.assertEqual(pomu_status(self.REPO_PATH), True)
+ init_plain_repo(True, self.REPO_DIR).expect()
+ self.assertEqual(pomu_status(self.REPO_DIR), True)
def testNonGitInitialization(self):
- makedirs(self.REPO_PATH)
- self.assertEqual(init_pomu(self.REPO_PATH).err(), 'target repository should be a git repo')
+ os.makedirs(self.REPO_DIR)
+ self.assertEqual(init_pomu(self.REPO_DIR).err(), 'target repository should be a git repo')
+
+class PortageRepoInitialization(unittest.TestCase):
+
+ def setUp(self):
+ os.environ['EROOT'] = REPO_PATH
+ os.environ['ROOT'] = REPO_PATH
+ os.environ['PORTAGE_CONFIGROOT'] = REPO_PATH
+ rcp = os.path.join(REPO_PATH, 'etc/portage/repos.conf')
+ os.makedirs(rcp)
+ with open(os.path.join(rcp, 'gentoo.conf'), 'w') as f:
+ f.write('[DEFAULT]\nmain-repo = gentoo\n[gentoo]\nlocation=/usr/portage\n')
+ importlib.reload(portage)
+ self.REPO_DIR = REPO_DIR
+
+ def tearDown(self):
+ rmtree(REPO_PATH)
+
+ def testRepoList(self):
+ self.assertEqual(list(portage_repos()), ['gentoo'])
+
+ def testPortageCreate(self)
+ self.assertTrue(init_portage_repo(True, REPO_DIR, REPO_PATH).is_ok())
+ self.assertEqual(pomu_active_repo(), REPO_DIR)