def test_missing_credential_file(self): with self.assertRaises(FileNotFoundError): Credentials("nonexistant.yaml")
def test_bad_yaml_file(self): with self.assertRaises(yaml.YAMLError): Credentials("bad_yaml_file.yaml")
def test_bad_permissions_file(self): with self.assertRaises(PermissionError): Credentials("bad_permissions.yaml")
def test_bad_dir(self): os.environ["IIP_CREDENTIAL_DIR"] = os.path.join(self.package, "tests", "files", "nothing") with self.assertRaises(PermissionError): Credentials("iip_cred.yaml")
def test_missing_credentials(self): del os.environ["IIP_CREDENTIAL_DIR"] os.environ["HOME"] = "/tmp" with self.assertRaises(PermissionError): Credentials("iip_cred.yaml") del os.environ["HOME"]
def test_credentials(self): cred = Credentials("iip_cred.yaml") self.assertEqual(cred.getUser("service_user"), "fakeuser") self.assertEqual(cred.getPasswd("service_passwd"), "fakepass")
def __init__(self, name, config_filename, log_filename): self._name = name self._config = self.loadConfigFile(config_filename) self.setupLogging(log_filename) self._cred = Credentials('iip_cred.yaml')