~racb/git-ubuntu:importer-add-tests

Last commit made on 2019-12-10
Get this branch:
git clone -b importer-add-tests https://git.launchpad.net/~racb/git-ubuntu
Only Robie Basak can upload to this branch. If you are Robie Basak please log in for upload directions.

Branch merges

Branch information

Name:
importer-add-tests
Repository:
lp:~racb/git-ubuntu

Recent commits

b5ac84c... by Robie Basak

Add importer tests

095bf9b... by Robie Basak

source_builder: add mutate attribute to SourceSpec

8ed8095... by Robie Basak

repo_builder: add Commit.from_spec method

A common test pattern is to create a Commit whose tree is a SourceTree
defined by a Source that is defined by a SourceSpec.

Rather than instantiating this in a complex nested call of constructors
every time, this new Commit.from_spec constructor classmethod does it
all at once, distributing the correct keyword arguments to the correct
constructors.

This allows much more concise test input data both for existing tests
(refactored) and for tests that will be added later in this branch.

7ffa268... by Robie Basak

Calculate validation_repo only when it is used

It's clearer if validation_repo is computed only immediately before the
assertions are made. This allows tests to better follow the pattern
(setup, execute, verify); computing validation_repo is only necessary,
by definition, in the verify step.

55a4bb6... by Robie Basak

Test conciseness, consistency and terminology

Allow Repo() and Repo.copy() to take default "nothing" arguments, and
make the terminology consistent with behaviour ("update" matches
dict.update; "list" is implicit as a Python sequence). Clean up all
calls to Repo() and Repo.copy().

Use "input_repo" to describe the test parameter that supplies a input
repository to the behaviour under test.

Use "validation_repo" to describe a repository that is to be compared
against to verify an expected result in the case that it isn't exactly
the expected repository.

Use "validation_repo_delta" to describe how to derive validation_repo
from input_repo.

Use "validation_repo_expected_identical_refs" to describe a subset of
references inside validation_repo that are expected to be identical
between validation_repo and actual results.

This change is not intended to make any functional change to the tests.
Docstrings are added where they were previously missing.

6688d2f... by Robie Basak

Break out repo_builder tests

We now have a standard that tests for foo.py are placed in foo_test.py,
so move these across to be consistent with our standard before we touch
them.

a3aac0a... by Robie Basak

SourceSpec: change default to non-native

It seems to be far more common that tests use non-native fake source
packages, so make this the default. This simplifies the call to the
SourceSpec constructor in many tests.

921fb12... by Robie Basak

repo_builder.Commit: default to empty tree

An empty tree is a common pattern in tests, so permit it to not be
specified and default to an empty tree if it is not. This makes many
tests more concise.

0b9f756... by Robie Basak

Add docstring for Commit constructor

e4fe528... by Robie Basak

Import Placeholder to avoid qualification

Placeholder is used everywhere in this file, so import it into our
namespace directly to tidy up all the references to it. This makes the
test input data easier to read.