def test_host_name_required_validation_infra():
    """Test to validate the hostname while adding a provider"""
    endpoint = VirtualCenterEndpoint(hostname=None)
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5),
                          endpoints=endpoint)

    with pytest.raises(AssertionError):
        prov.create()

    view = prov.create_view(prov.endpoints_form)
    assert view.hostname.help_block == "Required"
    view = prov.create_view(InfraProviderAddView)
    assert not view.add.active
Exemplo n.º 2
0
def test_infrastructure_add_provider_trailing_whitespaces():
    """Test to validate the hostname and username should be without whitespaces"""
    credentials = Credential(principal="test test", secret=fauxfactory.gen_alphanumeric(5))
    endpoint = VirtualCenterEndpoint(hostname="test test", credentials=credentials)
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint)
    with pytest.raises(AssertionError):
        prov.create()

    view = prov.create_view(prov.endpoints_form)
    assert view.hostname.help_block == "Spaces are prohibited"
    assert view.username.help_block == "Spaces are prohibited"
    view = prov.create_view(InfraProviderAddView)
    assert not view.add.active
Exemplo n.º 3
0
def test_infrastructure_add_provider_trailing_whitespaces():
    """Test to validate the hostname and username should be without whitespaces"""
    credentials = Credential(principal="test test", secret=fauxfactory.gen_alphanumeric(5))
    endpoint = VirtualCenterEndpoint(hostname="test test", credentials=credentials)
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint)
    with pytest.raises(AssertionError):
        prov.create()

    view = prov.create_view(prov.endpoints_form)
    assert view.hostname.help_block == "Spaces are prohibited"
    assert view.username.help_block == "Spaces are prohibited"
    view = prov.create_view(InfraProviderAddView)
    assert not view.add.active
Exemplo n.º 4
0
def test_host_name_required_validation_infra():
    """Test to validate the hostname while adding a provider"""
    endpoint = VirtualCenterEndpoint(hostname=None)
    prov = VMwareProvider(
        name=fauxfactory.gen_alphanumeric(5),
        endpoints=endpoint)

    with pytest.raises(AssertionError):
        prov.create()

    view = prov.create_view(prov.endpoints_form)
    assert view.hostname.help_block == "Required"
    view = prov.create_view(InfraProviderAddView)
    assert not view.add.active
Exemplo n.º 5
0
def test_host_name_required_validation():
    """Test to validate the hostname while adding a provider"""
    endpoint = VirtualCenterEndpoint(hostname=None)
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5),
                          endpoints=endpoint)

    err = FlashMessageException

    with error.expected(err):
        prov.create()

    view = prov.create_view(prov.endpoints_form)
    assert view.hostname.help_block == "Required"
    view = prov.create_view(ProviderAddView)
    assert not view.add.active
Exemplo n.º 6
0
def test_host_name_max_character_validation_infra():
    """Test to validate max character for host name field"""
    endpoint = VirtualCenterEndpoint(hostname=fauxfactory.gen_alphanumeric(256))
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint)
    try:
        prov.create()
    except AssertionError:
        view = prov.create_view(prov.endpoints_form)
        assert view.hostname.value == prov.hostname[0:255]
Exemplo n.º 7
0
def test_host_name_max_character_validation_infra():
    """Test to validate max character for host name field"""
    endpoint = VirtualCenterEndpoint(hostname=fauxfactory.gen_alphanumeric(256))
    prov = VMwareProvider(name=fauxfactory.gen_alphanumeric(5), endpoints=endpoint)
    try:
        prov.create()
    except AssertionError:
        view = prov.create_view(prov.endpoints_form)
        assert view.hostname.value == prov.hostname[0:255]
Exemplo n.º 8
0
def test_name_required_validation():
    """Tests to validate the name while adding a provider"""
    endpoint = VirtualCenterEndpoint(hostname=fauxfactory.gen_alphanumeric(5))
    prov = VMwareProvider(name=None, endpoints=endpoint)

    err = version.pick({
        version.LOWEST: "Name can't be blank",
        '5.6': FlashMessageException
    })

    with error.expected(err):
        prov.create()

    view = prov.create_view(ProviderAddView)
    assert view.name.help_block == "Required"
    assert not view.add.active