plainbox:abc: add IProvider1.get_units()

This patch exposes the Provider1.get_units() method via the IProvider1
interface. This is required to mock some providers with mocks that use
spec_set=IProvider1

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:symbol: make Symbol comparable via functools.total_ordering

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit: remove useless logging

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:legacy: super call validate() everywhere

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:validators: fix ShellProgramValidator not to crash in rare cases

This patch fixes a NameError that would be raised if token was never
set, which can happen if the syntax error happens on the first token.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:validators: tweak UnitReferenceValidator error message

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:exporter:xml Test for alphabetical ordering of test results.

Previously we'd show test results as they came straight from the result_map.
This makes for hard-to-read HTML reports (and any report that derives from
the XML one). This verifies that results (called 'questions' in our XML
schema) are ordered alphabetically in the XML result file, regardless of
their order in the result_map.

The sample .json data dump, used to produce the mock result_map, was
conveniently alphabetically ordered, so I flipped it to have this test fail.
Interestingly it also made a few other perfect-xml-match tests fail, since
they also relied on sample .json and .xml files having the same ordering.
plainbox:exporter:xml: Sort job results before converting to XML.

As long as other consumers of our XML reports don't want to reorder
questions, this guarantees test results will be output in alphabetical order.
plainbox:unit:validators: tweak UnitReferenceValidator

This patch adds a new intermediate class, ReferenceConstraint, that
couples a constraint_fn (function), message (str) and onlyif (function)

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:validators: make UnitValidationContext.provider_list a property

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
providers:checkbox: Add buildstamp attachment job
plainbox:unit:validators: don't use collections.abc

This patch removes the need for collections.abc that doesn't exist on
python3.2 that we still support.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: silence validate() deprecation warnings in tests

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: correct module docstring

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: add new UnitValidator class

This patch adds the new base unit validator class. Unlike in the past,
the new class should almost never have to be subclassed and extended
as it relies on field validators to do most of the heavy lifting.

The core APIs are the two new methods UnitValidator.check(unit)
and UnitValidator.check_in_context(unit, context) which look at
a particular unit and generate subsequent Issue instances that describe
all of the detected issues.

The check_in_context() method gets an additional UnitValidationContext
instance that allows to perform global analysis. This allows to verify
correctness of units in context of other units (checking that references
are correct, that identifiers are unique, etc).

In addition to the check() methods there are report_issue() family
of methods (including advice(), warning() and error() short-cuts) that
collaborate with the particular field validators to simplify the process
of reporting issues. All of the issues detected by a particular validator
are now collected and exposed as the new `all_issues` attribute.

Lastly there is the new explain() method that collaborates with
report_issue() to provide human-readable strings for various Problem
constants. It may be overridden in other classes to provide more accurate
error messages

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: make UnitValidator.make_field_validators() deterministic

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: fix PEP-8 issue

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: add Unit.is_translatable_field()

This patch adds a method that can be used to check if a given field
in the unit data was marked as translatable or not.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: remove Unit.get_unit_type()

This method is now also avialable via the UnitLegacyAPI so we should not
need a second copy here.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:unit:unit: add Unit.qualify_id()

This patch adds a method that can resolve relative unit identifiers
based on the namespace of the resolving unit's provider reference.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>