#!/usr/bin/env python
# -*- coding: utf-8 -*-

import httplib
import json

import nose.tools

import tests.test_SGHandler.base


class TestCase(tests.test_SGHandler.base.BaseSGHandlerTestCase):

    def test_unauthorized(self):
        """
        This case when failed to AWS authentication.
        """
        self.http_client.fetch(
            self.get_url(self.test_inbound_rules_url),
            self.stop,
            method='POST',
            body=json.dumps({})
        )
        response = self.wait()

        flag = True
        messages = list()

        if response.code != httplib.BAD_REQUEST:
            flag = False
            messages.append('Status Code is not 400.')

        if json.loads(response.body).get('status_code') != httplib.BAD_REQUEST:
            flag = False
            messages.append('Status Code in message body is not 400.')

        nose.tools.ok_(
            flag,
            msg='\n'.join(messages)
        )

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import httplib
import json
import logging

import tests.test_SGHandler.base


class TestCase(tests.test_SGHandler.base.BaseSGHandlerTestCase):

    def test_unauthorized(self):
        """
        This case when failed to AWS authentication.
        """
        self.http_client.fetch(
            self.get_url(self.test_inbound_rules_url),
            self.stop,
            method='POST',
            body=json.dumps({})
        )
        response = self.wait()
        logging.debug(response)
        json_response = json.loads(response.body)

        self.assertEqual(response.code, httplib.BAD_REQUEST)
        self.assertEqual(json_response.get('status_code'), httplib.BAD_REQUEST)

Change Assert method in test_post.py