Skip to content

Commit

Permalink
fix tests for netbox 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov committed Jan 17, 2024
1 parent a764f92 commit 2a0077e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions validity/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime

import django
import factory
from dcim.models import DeviceRole, DeviceType, Location, Manufacturer, Platform, Site
from extras.models import Tag
Expand All @@ -10,6 +11,9 @@
from validity.compliance.state import StateItem


DJANGO_MAJOR_VERSION = django.VERSION[:2]


class DataSourceFactory(DjangoModelFactory):
name = factory.Sequence(lambda n: f"datasource-{n}")
type = "local"
Expand All @@ -30,6 +34,11 @@ class DataFileFactory(DjangoModelFactory):
class Meta:
model = models.VDataFile

@factory.post_generation
def to_memoryview(self, **kwargs):
if DJANGO_MAJOR_VERSION < (4, 2) and isinstance(self.data, bytes):
self.data = memoryview(self.data)


class DataSourceLinkFactory(DjangoModelFactory):
data_source = factory.SubFactory(DataSourceFactory)
Expand Down

0 comments on commit 2a0077e

Please sign in to comment.