From c94c01482fb6cdbe017d33ed0668bcb80ba06017 Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Fri, 30 Jun 2017 04:49:25 +0300 Subject: Multiple changes and fixes for installation make package backend optional fix merge destination makedir properly add files to git index compare package slot with default the right way multiple fixes in writing metadata changed tests to reflect current code and pass --- tests/test_dispatch.py | 47 +++++++++++++++++++++++++---------------------- tests/test_init.py | 6 +++++- 2 files changed, 30 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/test_dispatch.py b/tests/test_dispatch.py index ebb450f..58d08fb 100644 --- a/tests/test_dispatch.py +++ b/tests/test_dispatch.py @@ -1,7 +1,7 @@ import shutil import unittest -from os import path +from os import path, makedirs from tempfile import mkdtemp from pomu.package import Package @@ -20,13 +20,15 @@ class DummySource(): @classmethod def fetch_package(cls, uri): - return Package(cls, 'test', cls.path) + return Package('test', cls.path, backend=cls, category='test') + class DispatcherTests(unittest.TestCase): def setUp(self): pomu_active_repo._drop() self.source_path = mkdtemp() - with open(path.join(self.source_path, 'test.ebuild'), 'w+') as f: + makedirs(path.join(self.source_path, 'test')) + with open(path.join(self.source_path, 'test', 'test.ebuild'), 'w+') as f: f.write('# Copytight 1999-2017\nAll Rights Reserved\nEAPI="0"\n') DummySource.path = self.source_path @@ -37,17 +39,18 @@ class DispatcherTests(unittest.TestCase): def testFetch(self): pkg = dispatcher.get_package('/test').unwrap() - self.assertEqual(pkg.files, [('', 'test.ebuild')]) + self.assertEqual(pkg.files, [('test', 'test.ebuild')]) def tearDown(self): shutil.rmtree(self.source_path) -""" + class InstallTests(unittest.TestCase): def setUp(self): pomu_active_repo._drop() self.source_path = mkdtemp() - with open(path.join(self.source_path, 'test.ebuild'), 'w+') as f: + makedirs(path.join(self.source_path, 'test')) + with open(path.join(self.source_path, 'test', 'test.ebuild'), 'w+') as f: f.write('# Copytight 1999-2017\nAll Rights Reserved\nEAPI="0"\n') DummySource.path = self.source_path @@ -60,24 +63,24 @@ class InstallTests(unittest.TestCase): shutil.rmtree(self.repo_dir) def testPkgCreate(self): - pkg = Package('test', self.source_path, files=['test.ebuild']) - self.assertEqual(pkg.files, [('', 'test.ebuild')]) - - def testPkgMerge(self): - pkg = Package('test', self.source_path) - self.repo.merge(pkg).expect() + pkg = Package('test', self.source_path, category='test', files=['test/test.ebuild']) + self.assertEqual(pkg.files, [('test', 'test.ebuild')]) def testPortagePkg(self): pkg = dispatcher.get_package('sys-apps/portage').expect() self.repo.merge(pkg).expect() - def testPkgUnmerge(self): - pkg = Package('test', self.source_path) - self.repo.merge(pkg).expect() - with self.subTest(i=0): - self.repo.unmerge(pkg).expect() - with self.subTest(i=1): - self.repo.remove_package('test').expect() - with self.subTest(i=2): - self.repo.remove_package('tset').expect_err() -""" +# TODO: convert to LocalEbuildFile backend +# def testPkgMerge(self): +# pkg = Package('test', self.source_path, category='test') +# self.repo.merge(pkg).expect() +# +# def testPkgUnmerge(self): +# pkg = Package('test', self.source_path, category='test') +# self.repo.merge(pkg).expect() +# with self.subTest(i=0): +# self.repo.unmerge(pkg).expect() +# with self.subTest(i=1): +# self.repo.remove_package('test').expect() +# with self.subTest(i=2): +# self.repo.remove_package('tset').expect_err() diff --git a/tests/test_init.py b/tests/test_init.py index 0c68324..bece6f9 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -30,7 +30,6 @@ class PlainRepoInitialization(unittest.TestCase): class PortageRepoInitialization(unittest.TestCase): def setUp(self): - pomu_active_repo._drop() os.environ['EROOT'] = REPO_PATH os.environ['ROOT'] = REPO_PATH os.environ['PORTAGE_CONFIGROOT'] = REPO_PATH @@ -42,6 +41,11 @@ class PortageRepoInitialization(unittest.TestCase): self.REPO_DIR = REPO_DIR def tearDown(self): + pomu_active_repo._drop() + del os.environ['EROOT'] + del os.environ['ROOT'] + del os.environ['PORTAGE_CONFIGROOT'] + importlib.reload(portage) rmtree(REPO_PATH) def testRepoList(self): -- cgit v1.2.3-18-g5258