Ejemplo n.º 1
0
 def test_load_config_ex(self, loader_mock=None, get_mock=None):
     """Test load config with exception."""
     CONST.__setattr__('NODE_NAME', 'MOCK_POD')
     with self.assertRaises(AssertionError):
         EnergyRecorder.energy_recorder_api = None
         EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api, None)
Ejemplo n.º 2
0
 def test_load_config_api_ko(self, loader_mock=None, get_mock=None):
     """Test load config with API unavailable."""
     CONST.__setattr__('NODE_NAME', 'MOCK_POD')
     EnergyRecorder.energy_recorder_api = None
     EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api["available"],
                       False)
Ejemplo n.º 3
0
 def test_load_config_ex(self, loader_mock=None, get_mock=None):
     """Test load config with exception."""
     for key in ['NODE_NAME', 'ENERGY_RECORDER_API_URL']:
         os.environ[key] = ''
         with self.assertRaises(AssertionError):
             EnergyRecorder.energy_recorder_api = None
             EnergyRecorder.load_config()
         self.assertEquals(EnergyRecorder.energy_recorder_api, None)
Ejemplo n.º 4
0
 def test_load_config_api_ko(self, loader_mock=None, get_mock=None):
     """Test load config with API unavailable."""
     os.environ['NODE_NAME'] = 'MOCK_POD'
     self._set_env_creds()
     EnergyRecorder.energy_recorder_api = None
     EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api["available"],
                       False)
Ejemplo n.º 5
0
 def test_load_config_no_creds(self, loader_mock=None, pod_mock=None):
     """Test load config without creds."""
     EnergyRecorder.energy_recorder_api = None
     EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api["auth"], None)
     self.assertEquals(
         EnergyRecorder.energy_recorder_api["uri"],
         "http://pod-uri:8888/recorders/environment/MOCK_POD")
 def test_load_config_no_creds(self, loader_mock=None, get_mock=None):
     """Test load config without creds."""
     CONST.__setattr__('NODE_NAME', 'MOCK_POD')
     EnergyRecorder.energy_recorder_api = None
     EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api["auth"], None)
     self.assertEquals(
         EnergyRecorder.energy_recorder_api["uri"],
         "http://pod-uri:8888/recorders/environment/MOCK_POD")
Ejemplo n.º 7
0
 def test_load_config(self, loader_mock=None, pod_mock=None):
     """Test load config."""
     EnergyRecorder.energy_recorder_api = None
     EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api["auth"],
                       ("user", "password"))
     self.assertEquals(
         EnergyRecorder.energy_recorder_api["uri"],
         "http://pod-uri:8888/recorders/environment/MOCK_POD")
Ejemplo n.º 8
0
    def test_load_config(self, loader_mock=None, get_mock=None):
        """Test load config."""
        os.environ['NODE_NAME'] = 'MOCK_POD'
        self._set_env_creds()
        EnergyRecorder.energy_recorder_api = None
        EnergyRecorder.load_config()

        self.assertEquals(EnergyRecorder.energy_recorder_api["auth"],
                          ("user", "password"))
        self.assertEquals(
            EnergyRecorder.energy_recorder_api["uri"],
            "http://pod-uri:8888/recorders/environment/MOCK_POD")
Ejemplo n.º 9
0
 def test_load_config_ex(self, loader_mock=None, pod_mock=None):
     """Test load config with exception."""
     with self.assertRaises(AssertionError):
         EnergyRecorder.energy_recorder_api = None
         EnergyRecorder.load_config()
     self.assertEquals(EnergyRecorder.energy_recorder_api, None)