File: CONTRIBUTING.md

package info (click to toggle)
python-distro 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 848 kB
  • sloc: python: 2,057; sh: 126; makefile: 107
file content (54 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# General

* Contributing to distro identification currently doesn't have any specific standards and rather depends on the specific implementation.
* A 100% coverage is expected for each PR unless explicitly authorized by the reviewer.
* Please try to maintain maximum code-health (via landscape.io).

# Contributing distro specific tests

Distro's tests are implemented via a standardized framework under `tests/test_distro.py`

For each distribution, tests should be added in the relevant class according to which distribution file(s) exists on it, so, for example, tests should be added under `TestOSRelease` where `/etc/os-release` is available.

The tests must be self-contained, meaning that the release files for the distribution should be maintained in the repository under `tests/resources/distros/distribution_name+distribution_version`.

A tests method would like somewhat like this:

```python
def test_centos7_os_release(self):
    desired_outcome = {
        'id': 'centos',
        'name': 'CentOS Linux',
        'pretty_name': 'CentOS Linux 7 (Core)',
        'version': '7',
        'pretty_version': '7 (Core)',
        'best_version': '7',
        'like': 'rhel fedora',
        'codename': 'Core'
    }
    self._test_outcome(desired_outcome)
```

The framework will automatically try to pick up the relevant file according to the method's name (`centos7` meaning the folder should be named `centos7` as well) and compare the `desired_outcome` with the parsed files found under the test dir.

The exception to the rule is under the `TestDistroRelease` test class which should look somewhat like this:

```python
def test_centos5_dist_release(self):
    desired_outcome = {
        'id': 'centos',
        'name': 'CentOS',
        'pretty_name': 'CentOS 5.11 (Final)',
        'version': '5.11',
        'pretty_version': '5.11 (Final)',
        'best_version': '5.11',
        'codename': 'Final',
        'major_version': '5',
        'minor_version': '11'
    }
    self._test_outcome(desired_outcome, 'centos', '5')
```

Where the name of the method is not indicative of the lookup folder but rather tha two last arguments in `_test_outcome`.

A test case is mandatory under `TestOverall` for a PR to be complete.