def test_view_on_error(self, token_is_valid, get):
        token_is_valid.return_value = True
        response_mock = Mock(status_code=404)
        error_msg = "No JSON object could be decoded"
        response_mock.json.side_effect = ValueError(error_msg)
        get.return_value = response_mock

        with self.assertRaises(Http404):
            DeployInfo.as_view()(self.request, deploy="53e143cb874ccb1f68000001")
Пример #2
0
    def test_view_on_error(self, token_is_valid, get):
        token_is_valid.return_value = True
        response_mock = Mock(status_code=404)
        error_msg = "No JSON object could be decoded"
        response_mock.json.side_effect = ValueError(error_msg)
        get.return_value = response_mock

        with self.assertRaises(Http404):
            DeployInfo.as_view()(self.request, deploy="53e143cb874ccb1f68000001")
 def test_view(self, get):
     response_mock = Mock()
     response_mock.json.return_value = self.data
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request,
                                     deploy="53e143cb874ccb1f68000001")
     self.assertEqual("deploys/deploy_details.html", response.template_name)
     self.assertDictEqual(self.data, response.context_data['deploy'])
     get.assert_called_with('{0}/deploys/{1}'.format(
         settings.TSURU_HOST, "53e143cb874ccb1f68000001"),
                            headers={'authorization': 'admin'})
 def test_view(self, get):
     response_mock = Mock()
     response_mock.json.return_value = self.data
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request,
                                     deploy="53e143cb874ccb1f68000001")
     self.assertEqual("deploys/deploy_details.html", response.template_name)
     self.assertDictEqual(self.data, response.context_data['deploy'])
     get.assert_called_with(
         '{0}/deploys/{1}'.format(settings.TSURU_HOST,
                                  "53e143cb874ccb1f68000001"),
         headers={'authorization': 'admin'}
     )
 def test_view(self, token_is_valid, get):
     token_is_valid.return_value = True
     response_mock = Mock(status_code=200)
     response_mock.json.return_value = copy.deepcopy(self.data)
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request, deploy="53e143cb874ccb1f68000001")
     self.assertIn("deploys/deploy_details.html", response.template_name)
     expected = copy.deepcopy(self.data)
     expected["Diff"] = u'<div class="highlight"><pre>%s\n</pre></div>\n' % self.data["Diff"]
     self.assertDictEqual(expected, response.context_data["deploy"])
     get.assert_called_with(
         "{0}/deploys/{1}".format(settings.TSURU_HOST, "53e143cb874ccb1f68000001"),
         headers={"authorization": "admin"},
     )
 def test_view_without_diff(self, token_is_valid, get):
     token_is_valid.return_value = True
     data = copy.deepcopy(self.data)
     del data["Diff"]
     response_mock = Mock()
     response_mock.json.return_value = copy.deepcopy(data)
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request, deploy="53e143cb874ccb1f68000001")
     self.assertIn("deploys/deploy_details.html", response.template_name)
     expected = copy.deepcopy(data)
     expected["Diff"] = None
     self.assertDictEqual(expected, response.context_data["deploy"])
     get.assert_called_with(
         '{0}/deploys/{1}'.format(settings.TSURU_HOST, "53e143cb874ccb1f68000001"),
         headers={'authorization': 'admin'}
     )
Пример #7
0
 def test_view_without_diff(self, token_is_valid, get):
     token_is_valid.return_value = True
     data = copy.deepcopy(self.data)
     del data["Diff"]
     response_mock = Mock(status_code=200)
     response_mock.json.return_value = copy.deepcopy(data)
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request, deploy="53e143cb874ccb1f68000001")
     self.assertIn("deploys/deploy_details.html", response.template_name)
     expected = copy.deepcopy(data)
     expected["Diff"] = None
     self.assertDictEqual(expected, response.context_data["deploy"])
     get.assert_called_with(
         '{0}/deploys/{1}'.format(settings.TSURU_HOST, "53e143cb874ccb1f68000001"),
         headers={'authorization': 'admin'}
     )
Пример #8
0
 def test_view(self, token_is_valid, get):
     token_is_valid.return_value = True
     response_mock = Mock(status_code=200)
     response_mock.json.return_value = copy.deepcopy(self.data)
     get.return_value = response_mock
     response = DeployInfo.as_view()(self.request,
                                     deploy="53e143cb874ccb1f68000001")
     self.assertIn("deploys/deploy_details.html", response.template_name)
     expected = copy.deepcopy(self.data)
     expected["Diff"] = u"<div class=\"highlight\"><pre>%s\n</pre></div>\n" % self.data["Diff"]
     self.assertDictEqual(expected, response.context_data['deploy'])
     get.assert_called_with(
         '{0}/deploys/{1}'.format(settings.TSURU_HOST,
                                  "53e143cb874ccb1f68000001"),
         headers={'authorization': 'admin'}
     )