mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-19 08:06:56 +02:00
Fix command line arg for Django 1.7 and make Python 2 and 3 compatible test
This commit is contained in:
parent
9606201200
commit
6418194b85
@ -55,9 +55,10 @@ class Command(BaseCommand):
|
|||||||
if VERSION < (1, 8):
|
if VERSION < (1, 8):
|
||||||
self.option_list += (
|
self.option_list += (
|
||||||
make_option(
|
make_option(
|
||||||
'--quiet', '-q',
|
'--quiet',
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
dest='quiet',
|
||||||
help='Hide details about each queue/message as they are processed'),
|
help='Hide details about each queue/message as they are processed'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from django.test import TestCase
|
|||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.test.client import Client
|
from django.test.client import Client
|
||||||
|
from django.utils import six
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
@ -38,13 +39,13 @@ class GetEmailTestCase(TestCase):
|
|||||||
test_email = "To: update.public@example.com\nFrom: comment@example.com\nSubject: Some Comment\n\nThis is the helpdesk comment via email."
|
test_email = "To: update.public@example.com\nFrom: comment@example.com\nSubject: Some Comment\n\nThis is the helpdesk comment via email."
|
||||||
with mock.patch('helpdesk.management.commands.get_email.listdir') as mocked_listdir, \
|
with mock.patch('helpdesk.management.commands.get_email.listdir') as mocked_listdir, \
|
||||||
mock.patch('helpdesk.management.commands.get_email.isfile') as mocked_isfile, \
|
mock.patch('helpdesk.management.commands.get_email.isfile') as mocked_isfile, \
|
||||||
mock.patch('builtins.open', mock.mock_open(read_data=test_email)):
|
mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=test_email)):
|
||||||
mocked_isfile.return_value = True
|
mocked_isfile.return_value = True
|
||||||
mocked_listdir.return_value = ['filename1', 'filename2']
|
mocked_listdir.return_value = ['filename1', 'filename2']
|
||||||
|
|
||||||
call_command('get_email')
|
call_command('get_email')
|
||||||
|
|
||||||
mocked_listdir.assert_called_with('/var/lib/mail/helpdesk')
|
mocked_listdir.assert_called_with('/var/lib/mail/helpdesk/')
|
||||||
mocked_isfile.assert_any_call('/var/lib/mail/helpdesk/filename1')
|
mocked_isfile.assert_any_call('/var/lib/mail/helpdesk/filename1')
|
||||||
mocked_isfile.assert_any_call('/var/lib/mail/helpdesk/filename2')
|
mocked_isfile.assert_any_call('/var/lib/mail/helpdesk/filename2')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user