~vcs-imports/reviewboard/trunk

« back to all changes in this revision

Viewing changes to reviewboard/testing/testcase.py

  • Committer: David Trowbridge
  • Date: 2021-08-17 05:08:34 UTC
  • mfrom: (4677.3.232)
  • Revision ID: git-v1:8d3e7034e141704fb932064aa596548fcea20fea
Merge remote-tracking branch 'origin/release-4.0.x'

Show diffs side-by-side

added added

removed removed

Lines of Context:
396
396
                          committer_name='Committer',
397
397
                          committer_email='committer@example.com',
398
398
                          committer_date=None,
 
399
                          with_diff=True,
399
400
                          **kwargs):
400
401
        """Create a DiffCommit for testing.
401
402
 
402
 
        This also creates a
 
403
        By default, this also parses the provided diff data and creates a
403
404
        :py:class:`reviewboard.diffviewer.models.filediff.FileDiff` attached to
404
 
        the commit.
 
405
        the commit. Callers can turn this off using ``with_diff=False``.
 
406
 
 
407
        Version Changed:
 
408
            4.0.5:
 
409
            Added the ``with_diff`` option.
405
410
 
406
411
        Args:
407
412
            repository (reviewboard.scmtools.models.Repository, optional):
443
448
            committer_date (datetime.datetime, optional):
444
449
                The date the commit was committed, if any.
445
450
 
 
451
            with_diff (bool, optional):
 
452
                Whether to create this with a diff.
 
453
 
 
454
                If ``True`` (the default), this will also create a
 
455
                :py:class:`~reviewboard.diffviewer.models.filediff.FileDiff`
 
456
                based on ``diff_contents`` and ``parent_diff_contents``.
 
457
                The diffs will be parsed using the repository's tool's native
 
458
                parser in order to create the commit.
 
459
 
 
460
                If ``False``, this will just create the object in the
 
461
                database.
 
462
 
446
463
            **kwargs (dict):
447
464
                Keyword arguments to be passed to the
448
465
                :py:class:`~reviewboard.diffviewer.models.diffcommit.
477
494
        else:
478
495
            parent_diff_file_name = None
479
496
 
480
 
        return DiffCommit.objects.create_from_data(
481
 
            repository=repository,
482
 
            diff_file_name='diff',
483
 
            diff_file_contents=diff_contents,
484
 
            parent_diff_file_name=parent_diff_file_name,
485
 
            parent_diff_file_contents=parent_diff_contents,
486
 
            diffset=diffset,
487
 
            commit_id=commit_id,
488
 
            parent_id=parent_id,
489
 
            author_name=author_name,
490
 
            author_email=author_email,
491
 
            author_date=author_date,
492
 
            commit_message=commit_message,
493
 
            request=None,
494
 
            committer_name=committer_name,
495
 
            committer_email=committer_email,
496
 
            committer_date=committer_date,
497
 
            check_existence=False,
498
 
            **kwargs)
 
497
        if with_diff:
 
498
            return DiffCommit.objects.create_from_data(
 
499
                repository=repository,
 
500
                diff_file_name='diff',
 
501
                diff_file_contents=diff_contents,
 
502
                parent_diff_file_name=parent_diff_file_name,
 
503
                parent_diff_file_contents=parent_diff_contents,
 
504
                diffset=diffset,
 
505
                commit_id=commit_id,
 
506
                parent_id=parent_id,
 
507
                author_name=author_name,
 
508
                author_email=author_email,
 
509
                author_date=author_date,
 
510
                commit_message=commit_message,
 
511
                request=None,
 
512
                committer_name=committer_name,
 
513
                committer_email=committer_email,
 
514
                committer_date=committer_date,
 
515
                check_existence=False,
 
516
                **kwargs)
 
517
        else:
 
518
            return DiffCommit.objects.create(
 
519
                diffset=diffset,
 
520
                commit_id=commit_id,
 
521
                parent_id=parent_id,
 
522
                author_name=author_name,
 
523
                author_email=author_email,
 
524
                author_date=author_date,
 
525
                commit_message=commit_message,
 
526
                committer_name=committer_name,
 
527
                committer_email=committer_email,
 
528
                committer_date=committer_date,
 
529
                **kwargs)
499
530
 
500
531
    def create_diffset(self, review_request=None, revision=1, repository=None,
501
532
                       draft=False, name='diffset'):