-
Couldn't load subscription status.
- Fork 3
Controller: introduce action_create_import() #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rezib
wants to merge
4
commits into
cea-hpc:master
Choose a base branch
from
rezib:pr/action_create_import
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
| make_parser, | ||
| ) | ||
| from rift.Package import Package | ||
| from rift.RPM import RPM | ||
| from rift.RPM import RPM, Spec | ||
| from rift.run import RunResult | ||
| from rift import RiftError | ||
|
|
||
|
|
@@ -44,6 +44,145 @@ def test_main_version(self): | |
| self.assert_except(SystemExit, "0", main, ['--version']) | ||
|
|
||
|
|
||
| class ControllerProjectActionCreateTest(RiftProjectTestCase): | ||
| """ | ||
| Tests class for Controller action create | ||
| """ | ||
|
|
||
| def test_create_missing_pkg_module_reason(self): | ||
| """create without package, module or reason fails""" | ||
| for cmd in (['create', '-m', 'Great module', '-r', 'Good reason'], | ||
| ['create', 'pkg', '-r', 'Good reason'], | ||
| ['create', 'pkg', '-m', 'Great module']): | ||
| with self.assertRaisesRegex(SystemExit, "2"): | ||
| main(cmd) | ||
|
|
||
| def test_create_missing_maintainer(self): | ||
| """create without maintainer""" | ||
| with self.assertRaisesRegex(RiftError, "You must specify a maintainer"): | ||
| main(['create', 'pkg', '-m', 'Great module', '-r', 'Good reason']) | ||
|
|
||
| def test_create(self): | ||
| """simple create""" | ||
| main(['create', 'pkg', '-m', 'Great module', '-r', 'Good reason', | ||
| '--maintainer', 'Myself']) | ||
| pkg = Package('pkg', self.config, self.staff, self.modules) | ||
| pkg.load() | ||
| self.assertEqual(pkg.module, 'Great module') | ||
| self.assertEqual(pkg.reason, 'Good reason') | ||
| self.assertCountEqual(pkg.maintainers, ['Myself']) | ||
| os.unlink(pkg.metafile) | ||
| os.rmdir(os.path.dirname(pkg.metafile)) | ||
|
|
||
| def test_create_unknown_maintainer(self): | ||
| """create with unknown maintainer fails""" | ||
| with self.assertRaisesRegex( | ||
| RiftError, "Maintainer 'Fail' is not defined"): | ||
| main(['create', 'pkg', '-m', 'Great module', '-r', 'Good reason', | ||
| '--maintainer', 'Fail']) | ||
|
|
||
|
|
||
| class ControllerProjectActionImportTest(RiftProjectTestCase): | ||
| """ | ||
| Tests class for Controller action import | ||
| """ | ||
| @property | ||
| def src_rpm(self): | ||
| return os.path.join( | ||
| os.path.dirname(os.path.abspath(__file__)), 'materials', 'pkg-1.0-1.src.rpm' | ||
| ) | ||
|
|
||
| @property | ||
| def bin_rpm(self): | ||
| return os.path.join( | ||
| os.path.dirname(os.path.abspath(__file__)), 'materials', 'pkg-1.0-1.noarch.rpm' | ||
| ) | ||
|
|
||
| def test_import_missing_pkg_module_reason(self): | ||
| """import without package, module or reason fails""" | ||
| for cmd in (['import', '-m', 'Great module', '-r', 'Good reason'], | ||
| ['import', 'pkg.src.rpm', '-r', 'Good reason'], | ||
| ['import', 'pkg.src.rpm', '-m', 'Great module']): | ||
| with self.assertRaisesRegex(SystemExit, "2"): | ||
| main(cmd) | ||
|
|
||
| def test_import_missing_maintainer(self): | ||
| """import without maintainer""" | ||
| with self.assertRaisesRegex(RiftError, "You must specify a maintainer"): | ||
| main(['import', self.src_rpm, '-m', 'Great module', '-r', 'Good reason']) | ||
|
|
||
| def test_import_bin_rpm(self): | ||
| """import binary rpm""" | ||
| with self.assertRaisesRegex( | ||
| RiftError, | ||
| ".*pkg-1.0-1.noarch.rpm is not a source RPM$"): | ||
| main(['import', self.bin_rpm, '-m', 'Great module', | ||
| '-r', 'Good reason', '--maintainer', 'Myself']) | ||
|
|
||
| def test_import(self): | ||
| """simple import""" | ||
| main(['import', self.src_rpm, '-m', 'Great module', '-r', 'Good reason', | ||
| '--maintainer', 'Myself']) | ||
| pkg = Package('pkg', self.config, self.staff, self.modules) | ||
| pkg.load() | ||
| self.assertEqual(pkg.module, 'Great module') | ||
| self.assertEqual(pkg.reason, 'Good reason') | ||
| self.assertCountEqual(pkg.maintainers, ['Myself']) | ||
| spec = Spec(filepath=pkg.specfile) | ||
| spec.load() | ||
| self.assertEqual(spec.changelog_name, 'Myself <[email protected]> - 1.0-1') | ||
| self.assertEqual(spec.version, '1.0') | ||
| self.assertEqual(spec.release, '1') | ||
| self.assertTrue(os.path.exists(f"{pkg.specfile}.orig")) | ||
| shutil.rmtree(os.path.dirname(pkg.metafile)) | ||
|
|
||
| def test_import_unknown_maintainer(self): | ||
| """import with unknown maintainer fails""" | ||
| with self.assertRaisesRegex( | ||
| RiftError, "Maintainer 'Fail' is not defined"): | ||
| main(['import', self.src_rpm, '-m', 'Great module', | ||
| '-r', 'Good reason', '--maintainer', 'Fail']) | ||
|
|
||
|
|
||
| class ControllerProjectActionReimportTest(RiftProjectTestCase): | ||
| """ | ||
| Tests class for Controller actionre import | ||
| """ | ||
| @property | ||
| def src_rpm(self): | ||
| return os.path.join( | ||
| os.path.dirname(os.path.abspath(__file__)), 'materials', 'pkg-1.0-1.src.rpm' | ||
| ) | ||
|
|
||
| @property | ||
| def bin_rpm(self): | ||
| return os.path.join( | ||
| os.path.dirname(os.path.abspath(__file__)), 'materials', 'pkg-1.0-1.noarch.rpm' | ||
| ) | ||
|
|
||
| def test_reimport_missing_maintainer(self): | ||
| """reimport without maintainer""" | ||
| with self.assertRaisesRegex(RiftError, "You must specify a maintainer"): | ||
| main(['reimport', self.src_rpm, '-m', 'Great module', '-r', 'Good reason']) | ||
|
|
||
| def test_reimport(self): | ||
| """simple reimport""" | ||
| self.make_pkg(name='pkg') | ||
| main(['reimport', self.src_rpm, '--maintainer', 'Myself']) | ||
| pkg = Package('pkg', self.config, self.staff, self.modules) | ||
| pkg.load() | ||
| self.assertEqual(pkg.module, 'Great module') | ||
| self.assertEqual(pkg.reason, 'Missing feature') | ||
| self.assertCountEqual(pkg.maintainers, ['Myself']) | ||
| spec = Spec(filepath=pkg.specfile) | ||
| spec.load() | ||
| self.assertEqual(spec.changelog_name, 'Myself <[email protected]> - 1.0-1') | ||
| self.assertEqual(spec.version, '1.0') | ||
| self.assertEqual(spec.release, '1') | ||
| self.assertTrue(os.path.exists(f"{pkg.specfile}.orig")) | ||
| os.unlink(f"{pkg.specfile}.orig") | ||
|
|
||
|
|
||
| class ControllerProjectTest(RiftProjectTestCase): | ||
| """ | ||
| Tests class for Controller | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.