nautobot / nautobot-app-ssot

Single Source of Truth for Nautobot
https://docs.nautobot.com/projects/ssot/en/latest/
Other
34 stars 28 forks source link

Update Diffsync to 2.0.0 and perform Linting #433

Closed mattmiller87 closed 1 month ago

mattmiller87 commented 2 months ago

Closes: #

What's Changed

To Do

mattmiller87 commented 2 months ago

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
jdrew82 commented 2 months ago

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 commented 1 month ago

@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 commented 1 month ago

@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?