-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from damdam-s/uninstaller
Add uninstalling capacity
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
* load a csv, xml or yaml file | ||
* add a xmlid on a record | ||
* upsert a record | ||
* uninstall a module | ||
""" |
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016-2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from ..exceptions import AnthemError | ||
|
||
|
||
def uninstall(ctx, module_list): | ||
""" uninstall module """ | ||
if not module_list: | ||
raise AnthemError(u"You have to provide a list of " | ||
"module's name to uninstall") | ||
|
||
mods = ctx.env['ir.module.module'].search([('name', 'in', module_list)]) | ||
try: | ||
mods.button_immediate_uninstall() | ||
except: | ||
raise AnthemError(u'Cannot uninstall modules. See the logs') |
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Camptocamp SA | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html) | ||
|
||
import pytest | ||
import anthem.cli | ||
from anthem.lyrics.uninstaller import uninstall | ||
from anthem.exceptions import AnthemError | ||
|
||
|
||
def test_uninstall_1(): | ||
with anthem.cli.Context(None, anthem.cli.Options(test_mode=True)) as ctx: | ||
with pytest.raises(AnthemError) as excinfo: | ||
uninstall(ctx, []) | ||
excinfo.match(r'You have to provide a list of module.*') | ||
|
||
|
||
def test_uninstall_2(): | ||
with anthem.cli.Context(None, anthem.cli.Options(test_mode=True)) as ctx: | ||
ctx.env['ir.module.module'].search( | ||
[('name', '=', 'lunch')]).button_immediate_install() | ||
uninstall(ctx, ['lunch']) |