Created test for config handler

This commit is contained in:
Mike Scherbakov 2012-05-28 20:01:54 +04:00
parent 3c8fb7481c
commit cce1f93b60
5 changed files with 18 additions and 7 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@
# Vagrant housekeeping file
/.vagrant
# artifact from config handler
test.server.com.json

View File

@ -46,7 +46,7 @@ class ConfigHandler(BaseHandler):
def create(self, request, environment_id):
task = create_chef_config.delay(environment_id)
response = rc.ACCEPTED
response = rc.ALL_OK
response.content = TaskHandler.render_task(task)
return response

View File

@ -128,7 +128,7 @@ INSTALLED_APPS = (
# 'django.contrib.admindocs',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
TEST_RUNNER = 'nailgun.testrunner.MyRunner'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to

View File

@ -0,0 +1,6 @@
from django_nose import NoseTestSuiteRunner
from djcelery.contrib.test_runner import CeleryTestSuiteRunner
class MyRunner(NoseTestSuiteRunner, CeleryTestSuiteRunner):
pass

View File

@ -4,6 +4,7 @@ from django.test import TestCase
from django.core.urlresolvers import reverse
from nailgun.models import Environment, Node, Cookbook, Role
from nailgun.tasks import create_chef_config
class TestHandlers(TestCase):
@ -270,8 +271,9 @@ class TestHandlers(TestCase):
self.assertEquals(len(cooks_from_db), 1)
self.assertEquals(cooks_from_db[0].version, cook_ver)
#def test_jsons_created_for_chef_solo(self):
#resp = self.client.post('/api/environments/1/chef-config/')
#print resp.content
#raise
def test_jsons_created_for_chef_solo(self):
url = reverse('config_handler', kwargs={'environment_id': 1})
resp = self.client.post(url)
self.assertEquals(resp.status_code, 200)
resp_json = json.loads(resp.content)
self.assertEquals(len(resp_json['task_id']), 36)