Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit d1762e3

Browse files
authored
Slightly improve test factories (#482)
Whic working on the repo cleanup, I noticed frequent test failures related to `Branch.name` not being unique enough. This fixes that along with some other improvements, like being able to use `CommitWithReportFactory` in `worker` which was not possible previously because of imports that are only valid within `api`.
1 parent 3a2414f commit d1762e3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

shared/django_apps/core/tests/factories.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Meta:
1515
model = models.Repository
1616

1717
private = True
18-
name = factory.Faker("word")
18+
name = factory.Faker("slug")
1919
service_id = factory.Sequence(lambda n: f"{n}")
2020
author = factory.SubFactory(OwnerFactory)
2121
language = factory.Iterator(
@@ -109,8 +109,7 @@ def _create(cls, model_class, *args, **kwargs):
109109
# The following replaces the old `commits.report` JSON column
110110
# TODO: we may want to find another way to create this since the imports below
111111
# create a cyclic dependency
112-
113-
from reports.tests.factories import (
112+
from shared.django_apps.reports.tests.factories import (
114113
CommitReportFactory,
115114
ReportLevelTotalsFactory,
116115
UploadFactory,
@@ -222,7 +221,7 @@ class Meta:
222221
model = models.Branch
223222

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

228227

0 commit comments

Comments
 (0)