def test_hostname_max_character_validation(): """Test to validate max character for hostname field""" endpoint = RHOSEndpoint(hostname=fauxfactory.gen_alphanumeric(256), api_port=None, security_protocol=None) prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint) try: prov.create() except AssertionError: endpoints = prov.create_view(prov.endpoints_form) assert endpoints.default.hostname.value == prov.hostname[0:255]
def test_host_name_required_validation(request): """Test to validate the hostname while adding a provider""" prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), hostname=None, ip_address=fauxfactory.gen_ipaddr(prefix=[10])) request.addfinalizer(prov.delete_if_exists) # It must raise an exception because it keeps on the form with pytest.raises(AssertionError): prov.create() endpoints = prov.create_view(prov.endpoints_form) assert endpoints.default.hostname.help_block == "Required"
def test_api_port_max_character_validation(): """Test to validate max character for api port field""" endpoint = RHOSEndpoint(hostname=fauxfactory.gen_alphanumeric(5), api_port=fauxfactory.gen_alphanumeric(16), security_protocol='Non-SSL') prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint) try: prov.create() except AssertionError: view = prov.create_view(prov.endpoints_form) text = view.default.api_port.value assert text == prov.default_endpoint.api_port[0:15]
def test_host_name_required_validation(request): """Test to validate the hostname while adding a provider""" prov = OpenStackProvider( name=fauxfactory.gen_alphanumeric(5), hostname=None, ip_address=fauxfactory.gen_ipaddr(prefix=[10])) request.addfinalizer(prov.delete_if_exists) # It must raise an exception because it keeps on the form with pytest.raises(AssertionError): prov.create() endpoints = prov.create_view(prov.endpoints_form) assert endpoints.default.hostname.help_block == "Required"
def test_api_port_blank_validation(request): """Test to validate blank api port while adding a provider""" endpoint = RHOSEndpoint(hostname=fauxfactory.gen_alphanumeric(5), ip_address=fauxfactory.gen_ipaddr(prefix=[10]), api_port='', security_protocol='Non-SSL') prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint) request.addfinalizer(prov.delete_if_exists) # It must raise an exception because it keeps on the form with pytest.raises(AssertionError): prov.create() endpoints = prov.create_view(prov.endpoints_form) assert endpoints.default.api_port.help_block == "Required"