def test_raise_user_settings_error(self): """Raise UserSettingsError tests.""" my_settings = {} my_settings["af_url"] = os.environ["AF_TEST_URL"] # Missing authentication key(s) with pytest.raises(rtpy.UserSettingsError): my_settings["username"] = "******" af = rtpy.Rtpy(my_settings) # Supplying api key and credentials with pytest.raises(rtpy.UserSettingsError): my_settings["password"] = "******" my_settings["api_key"] = "1234..." af = rtpy.Rtpy(my_settings) # Supplying incorrect keys with pytest.raises(rtpy.UserSettingsError): my_settings["my_custom_field"] = "custom_value" af = rtpy.Rtpy(my_settings) del my_settings["api_key"] del my_settings["my_custom_field"] # Incorrect raw response value with pytest.raises(rtpy.UserSettingsError): my_settings["raw_response"] = 2 af = rtpy.Rtpy(my_settings) # Incorrect verbose level value with pytest.raises(rtpy.UserSettingsError): del my_settings["raw_response"] my_settings["verbose_level"] = 5 af = rtpy.Rtpy(my_settings)
def instantiate_af_object_with_credentials_helpers(self): """Configure a Rtpy object using a username and password.""" self.settings = {} self.settings["af_url"] = os.environ["AF_TEST_URL"] self.settings["username"] = os.environ["AF_TEST_USERNAME"] self.settings["password"] = os.environ["AF_TEST_PASSWORD"] self.af = rtpy.Rtpy(self.settings) self.py_version = sys.version_info
def instantiate_af_object_with_api_key_helpers(self): """Configure a Rtpy object using an api key.""" self.settings = {} self.settings["af_url"] = os.environ["AF_TEST_URL"] self.settings["username"] = os.environ["AF_TEST_USERNAME"] self.settings["password"] = os.environ["AF_TEST_PASSWORD"] self.af = rtpy.Rtpy(self.settings) try: self.af.security.revoke_api_key() except (self.af.AfApiError, self.af.MalformedAfApiError): pass r = self.af.security.create_api_key() del self.settings["username"] del self.settings["password"] self.settings["api_key"] = r["apiKey"] self.af = rtpy.Rtpy(self.settings) self.py_version = sys.version_info