Esempio n. 1
0
 def test_get_juju_info_empty_file(self):
     """
     If L{get_juju_info} is called with a configuration pointing to
     an empty file, it returns C{None}.
     """
     self.log_helper.ignore_errors(ValueError)
     self._create_tmp_juju_file("")
     self.assertIs(None, get_juju_info(self.stub_config))
     self.assertIn("Error attempting to read JSON", self.logfile.getvalue())
Esempio n. 2
0
 def test_get_juju_info(self):
     """
     L{get_juju_info} parses JSON data from the juju_filename file.
     """
     self._create_tmp_juju_file(SAMPLE_JUJU_INFO)
     juju_info = get_juju_info(self.stub_config)
     self.assertEqual(
         {
             u"environment-uuid": "DEAD-BEEF",
             u"machine-id": "1",
             u"private-address": "127.0.0.1",
             u"api-addresses": ["10.0.3.1:17070"]
         }, juju_info)
Esempio n. 3
0
    def test_get_juju_info_multiple_endpoints(self):
        """L{get_juju_info} turns space separated API addresses into a list."""
        juju_multiple_endpoints = json.dumps({
            "environment-uuid": "DEAD-BEEF",
            "machine-id": "0",
            "api-addresses": "10.0.3.1:17070 10.0.3.2:18080",
            "private-address": "127.0.0.1"
        })

        self._create_tmp_juju_file(juju_multiple_endpoints)
        juju_info = get_juju_info(self.stub_config)
        self.assertEqual(
            {
                "environment-uuid": "DEAD-BEEF",
                "machine-id": "0",
                "api-addresses": ["10.0.3.1:17070", "10.0.3.2:18080"],
                "private-address": "127.0.0.1"
            }, juju_info)
Esempio n. 4
0
 def test_get_juju_info_no_json_file(self):
     """
     If L{get_juju_info} is called with a configuration pointing to
     a directory containing no json files, it returns None.
     """
     self.assertIs(None, get_juju_info(self.stub_config))
Esempio n. 5
0
 def _get_juju_data(self):
     """Load Juju information."""
     juju_info = get_juju_info(self._config)
     if juju_info is None:
         return None
     self._juju_data = juju_info