nautobot-app-ssot icon indicating copy to clipboard operation
nautobot-app-ssot copied to clipboard

Update Diffsync to 2.0.0 and perform Linting

Open mattmiller87 opened this issue 10 months ago • 4 comments

Closes: #<ISSUE NUMBER GOES HERE>

What's Changed

To Do

  • [x] Explanation of Change(s)
  • [x] Added change log fragment(s) (for more information see the documentation)
  • [ ] Attached Screenshots, Payload Example
  • [ ] Unit, Integration Tests
  • [ ] Documentation Updates (when adding/changing features)
  • [ ] Outline Remaining Work, Constraints from Design

mattmiller87 avatar Apr 17 '24 21:04 mattmiller87

Running into an error on the unittest:

======================================================================
ERROR: test_annotations_subclassing (nautobot_ssot.tests.test_contrib_model.AnnotationsSubclassingTest.test_annotations_subclassing)
Test that annotations work properly with subclassing.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_ssot/tests/test_contrib_model.py", line 285, in test_annotations_subclassing
    adapter.load()
  File "/source/nautobot_ssot/contrib/adapter.py", line 175, in load
    self._load_objects(diffsync_model)
  File "/source/nautobot_ssot/contrib/adapter.py", line 82, in _load_objects
    for database_object in diffsync_model._get_queryset():
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/source/nautobot_ssot/contrib/model.py", line 45, in _get_queryset
    available_fields = {field.name for field in cls._model._meta.get_fields()}
                                                ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/fields.py", line 902, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'ModelPrivateAttr' object has no attribute '_meta'

Stderr:
/usr/local/lib/python3.11/site-packages/pydantic/_internal/_fields.py:160: UserWarning: Field "model_flags" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(

----------------------------------------------------------------------
Ran 1 test in 0.026s

mattmiller87 avatar Apr 19 '24 13:04 mattmiller87

Running into an error on the unittest:

======================================================================
ERROR: test_annotations_subclassing (nautobot_ssot.tests.test_contrib_model.AnnotationsSubclassingTest.test_annotations_subclassing)
Test that annotations work properly with subclassing.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_ssot/tests/test_contrib_model.py", line 285, in test_annotations_subclassing
    adapter.load()
  File "/source/nautobot_ssot/contrib/adapter.py", line 175, in load
    self._load_objects(diffsync_model)
  File "/source/nautobot_ssot/contrib/adapter.py", line 82, in _load_objects
    for database_object in diffsync_model._get_queryset():
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/source/nautobot_ssot/contrib/model.py", line 45, in _get_queryset
    available_fields = {field.name for field in cls._model._meta.get_fields()}
                                                ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/fields.py", line 902, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'ModelPrivateAttr' object has no attribute '_meta'

Stderr:
/usr/local/lib/python3.11/site-packages/pydantic/_internal/_fields.py:160: UserWarning: Field "model_flags" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(

----------------------------------------------------------------------
Ran 1 test in 0.026s

I think @Kircheneer will need to chime in here.

jdrew82 avatar Apr 19 '24 14:04 jdrew82

@Kircheneer I've rebased @mattmiller87 's branch on next so it has all the changes that have been made in develop. I'm now getting multiple tests failing with the same error about object has no attribute '_meta' and I can't figure out how to resolve. It seems like something related to the Django Model class?

jdrew82 avatar May 16 '24 15:05 jdrew82

@Kircheneer with @mattmiller87's correction and I've fixed the two Infoblox tests that were failing we're just down to two contrib tests. I'm not understanding what's wrong with the tests in question so can you look to see if you can fix the issue?

jdrew82 avatar May 17 '24 17:05 jdrew82