1
# Ubuntu Continuous Integration Engine
2
# Copyright 2014 Canonical Ltd.
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License version 3, as
6
# published by the Free Software Foundation.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranties of
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
# PURPOSE. See the GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
from django.test import TestCase
20
from django.core.management import call_command, CommandError
23
class TestCreatClient(TestCase):
25
def _call_create_client(self, redirect_uri):
27
fd, filepath = tempfile.mkstemp()
29
with os.fdopen(fd, 'rb+') as f:
30
call_command('create_client', redirect_uri, stdout=f)
33
self.assertIn(':', output)
37
def test_create_client_success(self):
38
output = self._call_create_client('http://example.com/')
41
def test_create_client_again_success(self):
42
"""Test that a second call with the same redirect_uri returns the
43
same data not new data."""
45
output = self._call_create_client('http://example.com/')
46
second_output = self._call_create_client('http://example.com/')
48
self.assertEqual(output, second_output)
50
def test_requires_argument_none(self):
51
with self.assertRaises(CommandError):
52
output = self._call_create_client(None)
55
def test_requires_argument_blank(self):
56
with self.assertRaises(CommandError):
57
output = self._call_create_client("")