Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
client = client_dup
# sanity check - do we actually have a duplicate
swapdup = client.get(Network, 9)
d = client._fetcher.fetch_latest(Network, FIRST_NET, 0, since=0)
assert d[0][0]['name'] == swapdup.name
# obj that doesn't exist remotely
assert client.get(Network, 12)
rs = all_resources()
client.update_all(rs, since=0)
assert client.get(Network, FIRST_NET)
# remotely deleted dup should be gone
B = peeringdb.get_backend()
with pytest.raises(B.object_missing_error()):
client.get(Network, 12)
def test_reversed(client_empty):
client = client_empty
# sanity check for empty client
B = peeringdb.get_backend()
with pytest.raises(B.object_missing_error()):
client.get(Network, FIRST_NET)
rs = all_resources()
rs = reversed(rs)
client.update_all(rs)
def test_dry_run(client_empty):
client = peeringdb.PeeringDB(helper.CONFIG, dry_run=True)
rs = all_resources()
client.update_all(rs)
# still empty?
with pytest.raises(peeringdb.get_backend().object_missing_error()):
client.get(Network, FIRST_NET)
def __init__(self, concrete):
backend = get_backend()
kinds = {kind: {} for kind in FieldGroups.GROUPS}
fields = backend.get_fields(concrete)
for field in fields:
name = field.name
related, multiple = backend.is_field_related(concrete, name)
if related:
if multiple:
group = kinds['many_refs']
else:
group = kinds['one_refs']
else:
group = kinds['scalars']
group[name] = field
self._fields = kinds
def get(self, res, pk):
"Get a resource instance by primary key (id)"
B = get_backend()
return B.get_object(B.get_concrete(res), pk)
def all(self, res):
"Get resources using a filter condition"
B = get_backend()
return B.get_objects(B.get_concrete(res))