1
0
mirror of https://github.com/oskar456/dzonegit.git synced 2024-05-11 05:55:41 +00:00

8 Commits
v0.13 ... v0.15

Author SHA1 Message Date
Ondřej Caletka
17cbd099de Version 0.15 2021-12-21 22:28:45 +01:00
Ondřej Caletka
d809e24172 Fixup tests for whitespace error handling 2021-12-21 22:24:17 +01:00
Dominik Pantůček
35d01a796e Apply whitespace check only on *.zone files. 2021-12-21 22:23:09 +01:00
sturmianseq
2f7776c0d1 Reverting the latest commit to avoid state pollution 2021-08-16 23:08:58 +02:00
sturmianseq
498d4a8b82 setup the correct pre-state for test_get_zone_name 2021-08-02 14:32:18 +02:00
Ondřej Caletka
a96597decb Migrate to GitHub Actions (#18)
* Migrate to GitHub Actions

* Drop Python 3.5 test

* Delete .travis.yml
2021-08-02 14:28:07 +02:00
Ondřej Caletka
8f952086aa Version 0.14 2020-05-26 11:12:38 +02:00
Ondřej Caletka
83a4049821 Fix tests when user.name and user.email are not defined
Fixes #15
2020-05-26 11:11:23 +02:00
5 changed files with 54 additions and 22 deletions

42
.github/workflows/python-test.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Instal BIND 9 utils
run: sudo apt-get install -y bind9utils
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

View File

@@ -1,17 +0,0 @@
before_install:
- sudo apt-get install -y bind9utils
language: python
python:
- "3.5"
- "3.6"
- "3.7"
- "nightly"
matrix:
allow_failures:
- python: "nightly"
install:
- pip install -e .
- pip install pytest
script:
- pytest
sudo: false

View File

@@ -56,9 +56,9 @@ def get_head(empty=False):
def check_whitespace_errors(against, revision=None):
if revision:
cmd = ["git", "diff-tree", "--check", against, revision]
cmd = ["git", "diff-tree", "--check", against, revision, "*.zone"]
else:
cmd = ["git", "diff-index", "--check", "--cached", against]
cmd = ["git", "diff-index", "--check", "--cached", against, "*.zone"]
r = subprocess.run(
cmd,
stdout=subprocess.PIPE,

View File

@@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
setup(
name="dzonegit",
version="0.13",
version="0.15",
description="Git hooks to manage a repository of DNS zones",
long_description=readme,
long_description_content_type="text/x-rst",

View File

@@ -15,6 +15,8 @@ def git_dir(tmpdir_factory):
d = tmpdir_factory.getbasetemp()
d.chdir()
subprocess.call(["git", "init"])
subprocess.call(["git", "config", "user.name", "dzonegit pytest"])
subprocess.call(["git", "config", "user.email", "nonexistent@example.com"])
return d
@@ -25,18 +27,22 @@ def test_get_head(git_dir):
subprocess.call(["git", "add", "dummy"])
subprocess.call(["git", "commit", "-m", "dummy"])
assert dzonegit.get_head() != "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
subprocess.call(["git", "update-ref", "-d", "HEAD"])
def test_check_whitespace_errors(git_dir):
git_dir.chdir()
git_dir.join("whitespace").write(" ")
subprocess.call(["git", "add", "whitespace"])
dzonegit.check_whitespace_errors(dzonegit.get_head())
git_dir.join("whitespace.zone").write(" ")
subprocess.call(["git", "add", "whitespace.zone"])
with pytest.raises(ValueError):
dzonegit.check_whitespace_errors(dzonegit.get_head())
subprocess.call(["git", "commit", "-m", "whitespace"])
with pytest.raises(ValueError):
dzonegit.check_whitespace_errors("HEAD~", dzonegit.get_head())
subprocess.call(["git", "rm", "-f", "whitespace"])
subprocess.call(["git", "rm", "-f", "whitespace*"])
subprocess.call(["git", "commit", "-m", "rm whitespace"])
dzonegit.check_whitespace_errors(dzonegit.get_head())
dzonegit.check_whitespace_errors("HEAD~", dzonegit.get_head())
@@ -122,7 +128,7 @@ def test_get_altered_files(git_dir):
assert files == {Path("dummy"), Path("new")}
# Refers to test_check_whitespace_errors
files = set(dzonegit.get_altered_files("HEAD~", "D", "HEAD"))
assert files == {Path("whitespace")}
assert files == {Path("whitespace"), Path("whitespace.zone")}
subprocess.call(["git", "checkout", "-f", "HEAD"])
assert set(dzonegit.get_altered_files("HEAD", "AM")) == set()
@@ -154,6 +160,7 @@ $ORIGIN eXample.com. ;coment
60 IN NS ns
ns.example.com. 60 IN A 192.0.2.1
"""
subprocess.call(["git", "config", "dzonegit.allowfancynames", "FALSE"])
assert "example.com" == dzonegit.get_zone_name(
"zones/example.com.zone", "",
)