Skip to content

Add add_or_update to DiffSync class. #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b2dc459
Add add_or_update to DiffSync class.
FragmentedPacket Oct 11, 2021
8161a2d
Merge branch 'main' of git://github.com/networktocode/diffsync into 5…
FragmentedPacket Oct 26, 2021
b172cf0
Update diffsync.add to only raise ObjectAlreadyExists if objects diff…
FragmentedPacket Oct 26, 2021
182542b
Pylint to pass for tests for diffsync.add
FragmentedPacket Oct 26, 2021
7ed20cb
Add get_or_create along with tests.
FragmentedPacket Oct 27, 2021
f4f63e4
Addressed some of the feedback from Glenn.
FragmentedPacket Oct 29, 2021
c4c32cf
Rename get_or_create/get_or_instantiate. Update tests.
FragmentedPacket Oct 29, 2021
e61b560
Add testing for update_or_create. Return object in ObjectAlreadyExist…
FragmentedPacket Oct 30, 2021
e917055
Update doc strings
FragmentedPacket Oct 31, 2021
8f3b328
Add example of new methods.
FragmentedPacket Oct 31, 2021
c43f789
Updates to add device to diffsync. Update tests. Update test names an…
FragmentedPacket Nov 6, 2021
95cb2f0
Few doc updates for licensing year. Remove var assignment for error t…
FragmentedPacket Nov 6, 2021
37b3bca
Update diffsync/__init__.py
FragmentedPacket Nov 8, 2021
93a0a74
Update tests/unit/test_diffsync.py
FragmentedPacket Nov 8, 2021
025a401
Require attrs for update_or, Set existing_object as attribute in Obje…
FragmentedPacket Nov 8, 2021
6c747f1
Add README.md to example-04. Add Example 04 to examples/index.rst
FragmentedPacket Nov 12, 2021
4f9bf4b
Use python 3.9.7 for black.
FragmentedPacket Nov 12, 2021
c970516
Update to support 3.9 and black for compatibility.
FragmentedPacket Nov 12, 2021
647d971
Believe I fixed the dependencies
FragmentedPacket Nov 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Few doc updates for licensing year. Remove var assignment for error t…
…hhat wasn't being used.
  • Loading branch information
FragmentedPacket committed Nov 6, 2021
commit 95cb2f00bf6dea6c50f66afd1d3217bde4bfd389
8 changes: 2 additions & 6 deletions examples/04-get-update-instantiate/backends.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Example of a DiffSync adapter implementation.
"""Example of a DiffSync adapter implementation using new helper methods.

Copyright (c) 2020 Network To Code, LLC <[email protected]>
Copyright (c) 2021 Network To Code, LLC <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -86,8 +86,6 @@ class BackendA(DiffSync):

type = "Backend A"

nb = None

def load(self):
"""Initialize the BackendA Object by loading some site, device and interfaces from DATA."""
for device_data in BACKEND_DATA_A:
Expand Down Expand Up @@ -118,8 +116,6 @@ class BackendB(DiffSync):

type = "Backend B"

nb = None

def load(self):
"""Initialize the BackendB Object by loading some site, device and interfaces from DATA."""
for device_data in BACKEND_DATA_B:
Expand Down
2 changes: 1 addition & 1 deletion examples/04-get-update-instantiate/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
"""Main executable for DiffSync "example1".
"""Main executable for DiffSync "04-get-update-instantiate".

Copyright (c) 2021 Network To Code, LLC <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion examples/04-get-update-instantiate/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Example models.

Copyright (c) 2020 Network To Code, LLC <[email protected]>
Copyright (c) 2021 Network To Code, LLC <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_diffsync_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_diffsync_model_subclass_add_remove(make_site, make_device, make_interfa
assert site1.devices == []
with pytest.raises(ObjectStoreWrongType):
site1.remove_child(device1_eth0)
with pytest.raises(ObjectNotFound) as error:
with pytest.raises(ObjectNotFound):
site1.remove_child(device1)

assert device1.interfaces == []
Expand Down