예제 #1
0
 def test_read_config(self):
     dummy_cfg = fakes.fake_config_file
     sav_region = pyrax.default_region
     sav_USER_AGENT = pyrax.USER_AGENT
     with utils.SelfDeletingTempfile() as cfgfile:
         file(cfgfile, "w").write(dummy_cfg)
         pyrax._read_config_settings(cfgfile)
     self.assertEqual(pyrax.default_region, "FAKE")
     self.assertTrue(pyrax.USER_AGENT.startswith("FAKE "))
     pyrax.default_region = sav_region
     pyrax.USER_AGENT = sav_USER_AGENT
예제 #2
0
 def test_read_config(self):
     dummy_cfg = fakes.fake_config_file
     sav_region = pyrax.default_region
     sav_USER_AGENT = pyrax.USER_AGENT
     with utils.SelfDeletingTempfile() as cfgfile:
         open(cfgfile, "w").write(dummy_cfg)
         pyrax._read_config_settings(cfgfile)
     self.assertEqual(pyrax.default_region, "FAKE")
     self.assertTrue(pyrax.USER_AGENT.startswith("FAKE "))
     pyrax.default_region = sav_region
     pyrax.USER_AGENT = sav_USER_AGENT
예제 #3
0
 def test_read_config_bad(self):
     sav_region = pyrax.default_region
     dummy_cfg = fakes.fake_config_file
     # Test invalid setting
     dummy_cfg = dummy_cfg.replace("custom_user_agent", "fake")
     sav_USER_AGENT = pyrax.USER_AGENT
     with utils.SelfDeletingTempfile() as cfgfile:
         file(cfgfile, "w").write(dummy_cfg)
         pyrax._read_config_settings(cfgfile)
     self.assertEqual(pyrax.USER_AGENT, sav_USER_AGENT)
     # Test bad file
     with utils.SelfDeletingTempfile() as cfgfile:
         file(cfgfile, "w").write("FAKE")
         self.assertRaises(exc.InvalidConfigurationFile, pyrax._read_config_settings, cfgfile)
     pyrax.default_region = sav_region
     pyrax.USER_AGENT = sav_USER_AGENT
예제 #4
0
 def test_read_config_bad(self):
     sav_region = pyrax.default_region
     dummy_cfg = fakes.fake_config_file
     # Test invalid setting
     dummy_cfg = dummy_cfg.replace("custom_user_agent", "fake")
     sav_USER_AGENT = pyrax.USER_AGENT
     with utils.SelfDeletingTempfile() as cfgfile:
         open(cfgfile, "w").write(dummy_cfg)
         pyrax._read_config_settings(cfgfile)
     self.assertEqual(pyrax.USER_AGENT, sav_USER_AGENT)
     # Test bad file
     with utils.SelfDeletingTempfile() as cfgfile:
         open(cfgfile, "w").write("FAKE")
         self.assertRaises(exc.InvalidConfigurationFile,
                 pyrax._read_config_settings, cfgfile)
     pyrax.default_region = sav_region
     pyrax.USER_AGENT = sav_USER_AGENT