Commit Graph

6 Commits

Author SHA1 Message Date
Ian H. Pittwood 4480ab5574 Restructure usage of test fixtures
Pytest includes a fixture that can be used to generate temporary
directories. Previously Pegleg had implemented a hombrewed version of a
temporary directory fixture. This change removes the homebrewed version
and replaces it with the tmpdir fixture.

Implement tmpdir fixture in tests

Upgrade all testing packages to use the latest features

Removes unused imports and organizes import lists

Removes mock package requirement and uses unittest.mock, included in
python >3.3

Implements a slightly cleaner method to get proxy info

Change-Id: If66e1cfba858d5fb8948529deb8fb2d32345f630
2019-07-29 11:37:36 -05:00
Felipe Monteiro b28788325f tests: Improve unit tests runtime performance
This patch set does 2 things:

1) Improves unit test runtime peformance via pytest-xdist [0]
2) Reduces finnicky nature of `is_connected` helpers which
   sometimes skip even when there is access to the internet;
   logic has been added to make these checks more accurate
   to avoid skipping tests

Note that while there are newer alternatives to pytest-xdist they
are only compatible with much newer versions of Python.

[0] https://pypi.org/project/pytest-xdist/

Change-Id: Ib04b48ebabca0551058e5e1065056f4e559fbfe6
2019-04-04 14:21:43 +00:00
Felipe Monteiro b50619b06d refactor: Use temp path fixture to automatically clean up
This patch set refactors uses of tempfile.mkdtemp() used
throughout many tests in Pegleg which leaves lingering temporary
directories around. Recently a fixture was introduced in [0] which
automatically cleans up after itself. This patch set applies the
fixture everywhere possible to minimize the testing footprint.

[0] https://review.openstack.org/#/c/609818/20/tests/unit/fixtures.py

Change-Id: Id4c1195c4f248b974a5396a429d651943a84ee83
2018-10-29 15:13:23 +00:00
Felipe Monteiro c498bfee81 fix: Parse revision out of SSH repo url
This patch set adds additional logic to properly handle parsing
out the revision from an SSH repo url. The issue was being
masked by unit tests whose automated logic for calculating
the expected revision mirrored the actual implementation.
Thus, the unit tests have also been refactored to take in
hardcoded expected values to ensure that the assertions are
foolproof around validating expected revisions.

Change-Id: I7aacb4792f6b2dfc08d3a7bb4c3f18bbcfc95b8a
2018-10-25 15:38:28 -04:00
Rick Bartra e3d37db45e Allow the repository clone path to be specified in the CLI
As it currently stands, Pegleg clones site repositories into the /tmp
directory. Even if the site repository already exists in the /tmp
directory it is still cloned there which results in wasted disk space.

This commit allows users to pass in a `clone_path` (-p) option to Pegleg
CLI commands that specify where to clone a site repository. If the clone
path matches the path of an existing repository, then a error message is
logged stating so. If the repository already exists in the clone path, the
user can either specify to use that local repo by passing it as the site
repository or they proceed by passing in a different clone path.

This commit also updates the logic that deletes the copy of the repo that
is created in the temporary folder to also delete the parent folder that
contains the copied repo. This scenario happens when using a local
repository as the site repository.

Addionally, this commit adds a cleanup fixture that removes files and
directories created in the temporary folder by the unit tests.

Change-Id: I1b2943493b8f201f337ea60006c009973dd941b3
2018-10-20 15:21:07 -04:00
Felipe Monteiro 893ea9f4bb Standardize Pegleg directory structure
This patch set standardizes the Pegleg directory
structure because of the following reasons:

1) src/bin/pegleg is not necessary and only makes
building (e.g. documentation building) and running
of tox targets unnecessarily difficult.
2) src/bin/pegleg is a Java-like standard that
bears no relevance to Python.

Change-Id: I37d39d3d6186b92f8fbfe234221c9e44da48cf10
2018-09-23 10:33:40 -04:00