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

Commit 1cbb277

Browse files
committed
Remove django-dynamic-factory usage in favor of existing factories
1 parent f57f178 commit 1cbb277

File tree

5 files changed

+88
-113
lines changed

5 files changed

+88
-113
lines changed

api/internal/tests/test_charts.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66

77
import pytest
88
from dateutil.relativedelta import relativedelta
9-
from ddf import G
109
from django.test import TestCase, override_settings
1110
from django.utils import timezone
1211
from factory.faker import faker
1312
from pytz import UTC
1413
from rest_framework.exceptions import ValidationError
1514
from rest_framework.reverse import reverse
16-
from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory
15+
from shared.django_apps.core.tests.factories import (
16+
CommitFactory,
17+
OwnerFactory,
18+
RepositoryFactory,
19+
)
1720

1821
from api.internal.chart.filters import apply_default_filters, apply_simple_filters
1922
from api.internal.chart.helpers import (
@@ -84,8 +87,7 @@ def setup_commits(
8487
ci_passed = True if meets_default_filters else False
8588
deleted = False if meets_default_filters else True
8689

87-
G(
88-
Commit,
90+
CommitFactory(
8991
repository=repo,
9092
branch=branch,
9193
timestamp=timestamp,
@@ -340,8 +342,7 @@ def test_apply_simple_filters_branch_filtering(self):
340342

341343
def test_annotate_commits_with_totals(self):
342344
with_complexity_commitid = "i230tky2"
343-
G(
344-
Commit,
345+
CommitFactory(
345346
commitid=with_complexity_commitid,
346347
totals={"n": 0, "h": 0, "p": 0, "m": 0, "c": 0, "C": 0, "N": 1},
347348
)
@@ -361,8 +362,7 @@ def test_annotate_commits_with_totals(self):
361362

362363
def test_annotate_commit_with_totals_no_complexity_sets_ratio_to_None(self):
363364
no_complexity_commitid = "sdfkjwepj42"
364-
G(
365-
Commit,
365+
CommitFactory(
366366
commitid=no_complexity_commitid,
367367
totals={"n": 0, "h": 0, "p": 0, "m": 0, "c": 0, "C": 0, "N": 0},
368368
)
@@ -524,22 +524,19 @@ def setUp(self):
524524
self.repo4.repoid,
525525
]
526526
)
527-
self.commit1 = G(
528-
model=Commit,
527+
self.commit1 = CommitFactory(
529528
repository=self.repo1,
530529
totals={"h": 100, "n": 120, "p": 10, "m": 10},
531530
branch=self.repo1.branch,
532531
state="complete",
533532
)
534-
self.commit2 = G(
535-
model=Commit,
533+
self.commit2 = CommitFactory(
536534
repository=self.repo2,
537535
totals={"h": 14, "n": 25, "p": 6, "m": 5},
538536
branch=self.repo2.branch,
539537
state="complete",
540538
)
541-
self.commit3 = G(
542-
model=Commit,
539+
self.commit3 = CommitFactory(
543540
repository=self.repo3,
544541
totals={"h": 14, "n": 25, "p": 6, "m": 5},
545542
branch=self.repo3.branch,
@@ -751,21 +748,19 @@ def test_first_complete_commit_date_returns_date_of_first_complete_commit_in_rep
751748
)
752749
self.user.permission = [repo1.repoid, repo2.repoid]
753750
self.user.save()
754-
G(
755-
model=Commit,
751+
CommitFactory(
756752
repository=repo1,
757753
branch=repo1.branch,
758754
state="pending",
759755
timestamp=timezone.now() - timedelta(days=7),
760756
)
761-
commit1 = G(
762-
model=Commit,
757+
commit1 = CommitFactory(
763758
repository=repo1,
764759
branch=repo1.branch,
765760
state="complete",
766761
timestamp=timezone.now() - timedelta(days=3),
767762
)
768-
G(model=Commit, repository=repo2, branch=repo2.branch, state="complete")
763+
CommitFactory(repository=repo2, branch=repo2.branch, state="complete")
769764

770765
qr = ChartQueryRunner(
771766
self.user,
@@ -795,8 +790,7 @@ def test_start_date(self):
795790
repo = RepositoryFactory(author=self.org, active=True)
796791
self.user.permission = [repo.repoid]
797792
self.user.save()
798-
commit = G(
799-
model=Commit,
793+
commit = CommitFactory(
800794
repository=repo,
801795
branch=repo.branch,
802796
state="complete",
@@ -957,15 +951,13 @@ def setUp(self):
957951
self.current_owner = OwnerFactory(
958952
permission=[self.repo1.repoid, self.repo2.repoid]
959953
)
960-
self.commit1 = G(
961-
model=Commit,
954+
self.commit1 = CommitFactory(
962955
repository=self.repo1,
963956
totals={"h": 100, "n": 120, "p": 10, "m": 10},
964957
branch=self.repo1.branch,
965958
state="complete",
966959
)
967-
self.commit2 = G(
968-
model=Commit,
960+
self.commit2 = CommitFactory(
969961
repository=self.repo2,
970962
totals={"h": 14, "n": 25, "p": 6, "m": 5},
971963
branch=self.repo2.branch,

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dependencies = [
1515
"django-cors-headers==3.7.0",
1616
"django-csp==3.8.0",
1717
"django-cursor-pagination==0.3.0",
18-
"django-dynamic-fixture==3.1.1",
1918
"django-filter==2.4.0",
2019
"django-model-utils==4.5.1",
2120
"django-postgres-extra>=2.0.8",

0 commit comments

Comments
 (0)