Пример #1
0
 def test_should_use_list_template(self, get):
     response_mock = Mock()
     response_mock.json.return_value = {}
     get.return_value = response_mock
     response = ListNode.as_view()(self.request)
     self.assertEqual("docker/list_node.html", response.template_name)
     expected = []
     self.assertListEqual(expected, response.context_data["nodes"])
     get.assert_called_with("{0}/docker/node".format(settings.TSURU_HOST),
                            headers={"authorization": "admin"})
Пример #2
0
 def test_should_use_list_template(self, get):
     response_mock = Mock()
     response_mock.json.return_value = {}
     get.return_value = response_mock
     response = ListNode.as_view()(self.request)
     self.assertEqual("docker/list_node.html", response.template_name)
     expected = []
     self.assertListEqual(expected, response.context_data["nodes"])
     get.assert_called_with(
         "{0}/docker/node".format(settings.TSURU_HOST),
         headers={"authorization": "admin"})
 def test_should_pass_addresses_to_the_template(self, token_is_valid, get):
     token_is_valid.return_value = True
     response_mock = Mock()
     response_mock.json.return_value = {
         "machines": None,
         "nodes": [
             {"Address": "http://128.0.0.1:4243",
                 "Metadata": {"LastSuccess": "2014-08-01T14:09:40-03:00",
                              "pool": "theonepool"},
              "Status": "ready"},
             {"Address": "http://127.0.0.1:2375",
              "Metadata": {"LastSuccess": "2014-08-01T14:09:40-03:00",
                           "pool": "theonepool"},
              "Status": "ready"},
             {"Address": "http://myserver.com:2375",
              "Metadata": {"LastSuccess": "2014-08-01T14:09:40-03:00",
                           "pool": "theonepool"},
              "Status": "ready"},
         ],
     }
     get.return_value = response_mock
     response = ListNode.as_view()(self.request)
     date = parser.parse("2014-08-01T14:09:40-03:00")
     expected = {"theonepool": [
         {"Address": "http://128.0.0.1:4243",
          "Units": 2,
          "Metadata": {"LastSuccess": date, "pool": "theonepool"},
          "Status": "ready"},
         {"Address": "http://127.0.0.1:2375",
          "Units": 2,
          "Metadata": {"LastSuccess": date, "pool": "theonepool"},
          "Status": "ready"},
         {"Address": "http://myserver.com:2375",
          "Units": 2,
          "Metadata": {"LastSuccess": date, "pool": "theonepool"},
          "Status": "ready"},
     ]}
     self.assertEqual(expected, response.context_data["pools"])
Пример #4
0
 def test_should_pass_addresses_to_the_template(self, get):
     response_mock = Mock()
     response_mock.json.return_value = {
         "machines": None,
         "nodes": [
             {"Address": "http://128.0.0.1:4243",
              "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                           "pool": "theonepool"},
              "Status": "ready"},
             {"Address": "http://127.0.0.1:2375",
              "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                           "pool": "theonepool"},
              "Status": "ready"},
             {"Address": "http://myserver.com:2375",
              "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                           "pool": "theonepool"},
              "Status": "ready"},
         ],
     }
     get.return_value = response_mock
     response = ListNode.as_view()(self.request)
     expected = [
         {"Address": "http://128.0.0.1:4243",
          "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                       "pool": "theonepool"},
          "Status": "ready"},
         {"Address": "http://127.0.0.1:2375",
          "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                       "pool": "theonepool"},
          "Status": "ready"},
         {"Address": "http://myserver.com:2375",
          "Metadata": {"LastSuccess": "2014-08-01T14:09:40Z",
                       "pool": "theonepool"},
          "Status": "ready"},
     ]
     self.assertListEqual(expected, response.context_data["nodes"])
Пример #5
0
 def test_should_pass_addresses_to_the_template(self, get):
     response_mock = Mock()
     response_mock.json.return_value = {
         "machines":
         None,
         "nodes": [
             {
                 "Address": "http://128.0.0.1:4243",
                 "Metadata": {
                     "LastSuccess": "2014-08-01T14:09:40Z",
                     "pool": "theonepool"
                 },
                 "Status": "ready"
             },
             {
                 "Address": "http://127.0.0.1:2375",
                 "Metadata": {
                     "LastSuccess": "2014-08-01T14:09:40Z",
                     "pool": "theonepool"
                 },
                 "Status": "ready"
             },
             {
                 "Address": "http://myserver.com:2375",
                 "Metadata": {
                     "LastSuccess": "2014-08-01T14:09:40Z",
                     "pool": "theonepool"
                 },
                 "Status": "ready"
             },
         ],
     }
     get.return_value = response_mock
     response = ListNode.as_view()(self.request)
     expected = [
         {
             "Address": "http://128.0.0.1:4243",
             "Metadata": {
                 "LastSuccess": "2014-08-01T14:09:40Z",
                 "pool": "theonepool"
             },
             "Status": "ready"
         },
         {
             "Address": "http://127.0.0.1:2375",
             "Metadata": {
                 "LastSuccess": "2014-08-01T14:09:40Z",
                 "pool": "theonepool"
             },
             "Status": "ready"
         },
         {
             "Address": "http://myserver.com:2375",
             "Metadata": {
                 "LastSuccess": "2014-08-01T14:09:40Z",
                 "pool": "theonepool"
             },
             "Status": "ready"
         },
     ]
     self.assertListEqual(expected, response.context_data["nodes"])