Skip to content

Commit

Permalink
Closes #108 As testbot I would like to enable and disable languages
Browse files Browse the repository at this point in the history
  • Loading branch information
tommydeboer committed May 23, 2019
1 parent c5b278a commit 9c6fbc9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
18 changes: 17 additions & 1 deletion mcmd/commands/disable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from mcmd import io
from mcmd.client import api
from mcmd.client.molgenis_client import post
from mcmd.client.molgenis_client import post, put
from mcmd.command import command
from mcmd.commands._registry import arguments
from mcmd.io import highlight
Expand All @@ -26,6 +26,15 @@ def add_arguments(subparsers):
type=str,
help="The entity type to remove the row level security from")

p_disable_language = p_disable_subparsers.add_parser('language',
help='Enables a language')
p_disable_language.set_defaults(func=disable_language,
write_to_history=True)
p_disable_language.add_argument('language',
type=str,
help="the language you want to disable, specified by the two letter code (e.g. "
"'en')")


# =======
# Methods
Expand All @@ -41,3 +50,10 @@ def disable_rls(args):
ensure_resource_exists(args.entity, ResourceType.ENTITY_TYPE)
post(api.rls(), data={'id': args.entity,
'rlsEnabled': False})


@command
def disable_language(args):
io.start('Disabling language {}'.format(highlight(args.language)))
url = api.rest1('sys_Language/{}/active'.format(args.language))
put(url, 'false')
17 changes: 16 additions & 1 deletion mcmd/commands/enable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from mcmd import io
from mcmd.client import api
from mcmd.client.molgenis_client import post
from mcmd.client.molgenis_client import post, put
from mcmd.command import command
from mcmd.commands._registry import arguments
from mcmd.io import highlight
Expand Down Expand Up @@ -37,6 +37,14 @@ def add_arguments(subparsers):
help='The bootstrap theme you want to enable, specify the name with or without '
'(.min).css and with or without bootstrap- prefix.')

p_enable_language = p_enable_subparsers.add_parser('language',
help='Enables a language')
p_enable_language.set_defaults(func=enable_language,
write_to_history=True)
p_enable_language.add_argument('language',
type=str,
help="The language you want to enable, specified by the two letter code (e.g. 'en')")


# =======
# Methods
Expand Down Expand Up @@ -72,3 +80,10 @@ def enable_theme(args):
else:
raise McmdError(
'Applying theme failed. No themes found containing {} in the name'.format(args.theme, 'sys_set_StyleSheet'))


@command
def enable_language(args):
io.start('Enabling language {}'.format(highlight(args.language)))
url = api.rest1('sys_Language/{}/active'.format(args.language))
put(url, 'true')
11 changes: 11 additions & 0 deletions tests/integration/commands/test_disable_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

from tests.integration.utils import run_commander


@pytest.mark.integration
def test_enable_language(session):
session.update_one('sys_Language', 'nl', 'active', True)

run_commander('disable language nl')
assert session.get_by_id('sys_Language', 'nl')['active'] is False
14 changes: 14 additions & 0 deletions tests/integration/commands/test_enable_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest

from tests.integration.utils import run_commander


@pytest.mark.integration
def test_enable_language(session):
session.update_one('sys_Language', 'nl', 'active', False)

run_commander('enable language nl')
assert session.get_by_id('sys_Language', 'nl')['active'] is True

# cleanup
session.update_one('sys_Language', 'nl', 'active', False)

0 comments on commit 9c6fbc9

Please sign in to comment.