Skip to content

Commit

Permalink
Tweaks to test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalex committed Jul 27, 2021
1 parent 6ec33d6 commit b62a612
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kolibri/core/auth/test/sync_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ def manage(self, *args):
def create_model(self, model, **kwargs):
kwarg_text = DjangoJSONEncoder().encode(kwargs)
self.pipe_shell(
"from {module_path} import {model_name}; {model_name}.objects.create({})".format(
'import json; from {module_path} import {model_name}; kwargs = json.loads("""{}"""); {model_name}.objects.create(**kwargs)'.format(
kwarg_text, module_path=model.__module__, model_name=model.__name__
)
)

def delete_model(self, model, **kwargs):
kwarg_text = DjangoJSONEncoder().encode(kwargs)
self.pipe_shell(
"from {module_path} import {model_name}; obj = {model_name}.objects.get({}); obj.delete()".format(
'import json; from {module_path} import {model_name}; kwargs = json.loads("""{}"""); obj = {model_name}.objects.get(**kwargs); obj.delete()'.format(
kwarg_text, module_path=model.__module__, model_name=model.__name__
)
)

def pipe_shell(self, text):
subprocess.call(
'echo "{}" | kolibri shell'.format(text), env=self.env, shell=True
"echo '{}' | kolibri shell".format(text), env=self.env, shell=True
)

def _wait_for_server_start(self, timeout=20):
Expand Down

0 comments on commit b62a612

Please sign in to comment.