Skip to content

Commit 62f4c74

Browse files
authored
Merge pull request #10 from luto/test-docs
support running the tests on Arch
2 parents 4d67554 + 65d6e54 commit 62f4c74

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,17 @@ autorestart=true
4646

4747
## Running tests
4848

49-
The tests expect to be run on a Debian or Ubuntu system using the official PowerDNS 4.1.x upstream packages. You'll need `pytest` and `pytest-flask` installed, as well as the `pdns-server` and `pdns-backend-sqlite3` OS packages.
49+
### Setup
5050

51-
You can then run tests by running `pytest -v` inside the source directory.
51+
* Ubuntu / Debian
52+
53+
The officially supported system for testing is Debian or Ubuntu. To start, install the the official PowerDNS 4.1.x upstream packages: `pdns-server` and `pdns-backend-sqlite3`.
54+
55+
* Arch
56+
57+
The tests can also be run on Arch Linux. Install the `powerdns` package.
58+
59+
Additonally a few python modules need to be installed to run the tests (mainly `pytest`): `pip install -r requirements-dev.txt`. You can then run tests by running `pytest -v` inside the source directory.
5260

5361
## Authenticating
5462

powerdns_auth_proxy/tests/test_proxy.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import base64
33
import json
44
import os
5+
import os.path
56
import subprocess
67
import tempfile
78
import time
@@ -67,9 +68,19 @@ def client():
6768
app = create_app(test_config)
6869
app.config['TESTING'] = True
6970

71+
72+
ALL_SCHEMA_PATHS = [
73+
'/usr/share/doc/pdns-backend-sqlite3/schema.sqlite3.sql',
74+
'/usr/share/doc/powerdns/schema.sqlite3.sql',
75+
]
76+
schema_paths = list(filter(os.path.exists, ALL_SCHEMA_PATHS))
77+
78+
if not schema_paths:
79+
raise Exception('Unsupported OS. Cannot find example sqlite schema. Looked in: ' + ':'.join(ALL_SCHEMA_PATHS))
80+
7081
# create an empty database from the supplied schema
7182
with closing(sqlite3.connect(pdns_db_path)) as db:
72-
with app.open_resource('/usr/share/doc/pdns-backend-sqlite3/schema.sqlite3.sql', mode='r') as f:
83+
with app.open_resource(schema_paths[0], mode='r') as f:
7384
db.cursor().executescript(f.read())
7485
db.execute("INSERT INTO domains (name, type, account) VALUES ('example.net', 'MASTER', 'nobody');") # create a domain that the demo user can't read later
7586
db.commit()

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
pytest-flask

0 commit comments

Comments
 (0)