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)
def test_resource_fullpath(): """Test the __eq__ operation for Resouces.""" data = resource_data() res1 = Resource(**data) assert res1.full_path() == "/Common/test_resource"
def test_resource_fullpath(): u"""Test the __eq__ operation for Resouces.""" data = resource_data() res1 = Resource(**data) assert res1.full_path() == "/Common/test_resource"
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)
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)
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 = {}
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"
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"
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)
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 = {}
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)
def test_resource_hash(): """Test the __eq__ operation for Resouces.""" data = resource_data() res1 = Resource(**data) res2 = Resource(**data) assert hash(res1) == hash(res2)
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
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
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
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
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
def test_resource_get_data(): """Test the __eq__ operation for Resouces.""" data = resource_data() res1 = Resource(**data) assert res1.data == data
def test_metedata_not_set(): """Test Resource data update.""" data = resource_data() res = Resource(**data) assert res.whitelist is False
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
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
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
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
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'
def test_create_resource_without_name(): """Test Resource instantiation without name.""" with pytest.raises(ValueError): res = Resource(name=None, partition=None)
def test_str(): """Test the str magic function.""" data = resource_data() res = Resource(**data) str(res) == "{'name': \"test_resource\", 'partition': \"Common\"}"