Files
edx-platform/common/djangoapps/track/management/tests/test_tracked_command.py
Feanil Patel 2df8b8226b Merge pull request #22643 from edx/feanil/2to3_asserts
Run `2to3 -f asserts . -w` on edx-platform.
2019-12-30 12:13:42 -05:00

28 lines
767 B
Python

import json
from six import StringIO
from django.core.management import call_command
from django.test import TestCase
class CommandsTestBase(TestCase):
"""
Command for testing track functionality
"""
def _run_dummy_command(self, *args, **kwargs):
"""
Calls the test command and outputs a dict of the current context.
"""
out = StringIO()
call_command('tracked_dummy_command', *args, stdout=out, **kwargs)
out.seek(0)
return json.loads(out.read())
def test_command(self):
args = ['whee']
kwargs = {'key1': 'default', 'key2': True}
json_out = self._run_dummy_command(*args, **kwargs)
self.assertEqual(json_out['command'].strip(), 'tracked_dummy_command')