Skip to content
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

Slightly improve test factories #482

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions shared/django_apps/core/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Meta:
model = models.Repository

private = True
name = factory.Faker("word")
name = factory.Faker("slug")
service_id = factory.Sequence(lambda n: f"{n}")
author = factory.SubFactory(OwnerFactory)
language = factory.Iterator(
Expand Down Expand Up @@ -109,8 +109,7 @@ def _create(cls, model_class, *args, **kwargs):
# The following replaces the old `commits.report` JSON column
# TODO: we may want to find another way to create this since the imports below
# create a cyclic dependency

from reports.tests.factories import (
from shared.django_apps.reports.tests.factories import (
CommitReportFactory,
ReportLevelTotalsFactory,
UploadFactory,
Expand Down Expand Up @@ -222,7 +221,7 @@ class Meta:
model = models.Branch

repository = factory.SubFactory(RepositoryFactory)
name = factory.Faker("sentence", nb_words=1)
name = factory.Faker("slug")
head = factory.LazyAttribute(lambda o: sha1(o.name.encode("utf-8")).hexdigest())


Expand Down
Loading