66
77import pytest
88from dateutil .relativedelta import relativedelta
9- from ddf import G
109from django .test import TestCase , override_settings
1110from django .utils import timezone
1211from factory .faker import faker
1312from pytz import UTC
1413from rest_framework .exceptions import ValidationError
1514from 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
1821from api .internal .chart .filters import apply_default_filters , apply_simple_filters
1922from 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 ,
0 commit comments