Esempio n. 1
0
def test_get_uri_path(bigip):
    u"""Test _uri_path throws NotImplemented."""
    data = resource_data()
    res = Resource(**data)

    with pytest.raises(NotImplementedError):
        res._uri_path(bigip)
Esempio n. 2
0
def test_resource_fullpath():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)

    assert res1.full_path() == "/Common/test_resource"
Esempio n. 3
0
def test_resource_fullpath():
    u"""Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)

    assert res1.full_path() == "/Common/test_resource"
Esempio n. 4
0
def test_get_uri_path(bigip):
    """Test _uri_path throws NotImplemented."""
    data = resource_data()
    res = Resource(**data)

    with pytest.raises(NotImplementedError):
        res._uri_path(bigip)
Esempio n. 5
0
def test_update_resource(bigip):
    """Test Resource update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(NotImplementedError):
        res.update(bigip)
Esempio n. 6
0
def test_set_data():
    """Test Resource data update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(AttributeError):
        res.data = {}
Esempio n. 7
0
def test_set_partition():
    u"""Test Resource partition update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(AttributeError):
        res.partition = "Common"
Esempio n. 8
0
def test_set_name():
    u"""Test Resource name update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(AttributeError):
        res.name = "test_resource"
Esempio n. 9
0
def test_read_resource(bigip):
    u"""Test Resource read."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(NotImplementedError):
        res.read(bigip)
Esempio n. 10
0
def test_set_data():
    u"""Test Resource data update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(AttributeError):
        res.data = {}
Esempio n. 11
0
def test_update_resource(bigip):
    u"""Test Resource update."""
    data = resource_data()

    res = Resource(name=data['name'], partition=data['partition'])

    with pytest.raises(NotImplementedError):
        res.update(bigip)
Esempio n. 12
0
def test_resource_hash():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(**data)

    assert hash(res1) == hash(res2)
Esempio n. 13
0
def test_resource_equal():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(**data)

    assert res1.__eq__(res2)
    assert res1 == res2
Esempio n. 14
0
def test_resource_equal():
    u"""Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(**data)

    assert res1.__eq__(res2)
    assert res1 == res2
Esempio n. 15
0
def test_resource_not_equal():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(name="other_resource", partition="Common")

    assert not res1.__eq__(res2)
    assert res1 != res2
    assert not res1 == res2
Esempio n. 16
0
def test_resource_less_than():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(name="other_resource", partition="Common")

    assert not res1 < res2
    assert res1 != res2
    assert res2 < res1
Esempio n. 17
0
def test_resource_not_equal():
    u"""Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)
    res2 = Resource(name="other_resource", partition="Common")

    assert not res1.__eq__(res2)
    assert res1 != res2
    assert not res1 == res2
Esempio n. 18
0
def test_resource_get_data():
    """Test the __eq__ operation for Resouces."""
    data = resource_data()

    res1 = Resource(**data)

    assert res1.data == data
Esempio n. 19
0
def test_metedata_not_set():
    """Test Resource data update."""
    data = resource_data()

    res = Resource(**data)

    assert res.whitelist is False
Esempio n. 20
0
def test_whitelist_false_metedata_property():
    """Test Resource data update."""
    data = resource_data()
    data['metadata'] = [{'name': 'cccl-whitelist', 'value': 'false'}]

    res = Resource(**data)

    assert len(res.data) == 3
    assert res.whitelist is False
Esempio n. 21
0
def test_unsupported_metedata_property():
    """Test Resource data update."""
    data = resource_data()
    data['metadata'] = [{'name': 'unsupported', 'value': '0'}]

    res = Resource(**data)

    # unsupported metadata is ignored
    assert len(res.data) == 3
    assert res.whitelist is False
Esempio n. 22
0
def test_create_resource_without_partition():
    """Test Resource instantiation without name."""
    data = resource_data()
    name = data.get('name', "")
    partition = data.get('partition', "")

    res = Resource(name=name, partition=None)

    assert res
    assert res.name == name
    assert not res.partition
    assert res.data
Esempio n. 23
0
def test_create_resource_with_data():
    """Test Resource instantiation with data."""
    data = resource_data()
    name = data.get('name', "")
    partition = data.get('partition', "")

    res = Resource(name=name, partition=partition)

    assert res
    assert res.name == name
    assert res.partition == partition
    assert res.data
Esempio n. 24
0
def test_ignore_unknown_properties():
    """Test Resource unknown base properties."""
    data = resource_data()
    data['prop1'] = 'property1'
    data['prop2'] = 'property2'
    assert len(data) == 4

    res = Resource(**data)

    assert len(res.data) == 2
    assert res.whitelist is False

    with pytest.raises(KeyError):
        _ = res.data['prop1']
    with pytest.raises(KeyError):
        _ = res.data['prop2']
    assert res.data['name'] == 'test_resource'
    assert res.data['partition'] == 'Common'
Esempio n. 25
0
def test_create_resource_without_name():
    """Test Resource instantiation without name."""
    with pytest.raises(ValueError):
        res = Resource(name=None, partition=None)
Esempio n. 26
0
def test_str():
    """Test the str magic function."""
    data = resource_data()
    res = Resource(**data)

    str(res) == "{'name': \"test_resource\", 'partition': \"Common\"}"