Skip to content

Commit d62f99a

Browse files
committed
Rename stage => files
1 parent 66cc14a commit d62f99a

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__pycache__
33
.coverage
44
reports/
5-
stage/
5+
files/
66
downloads/
77
config/
88
config.json

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all: # TODO: include integration test with backends such as QPM
1212
@. .venv/bin/activate && coverage run --branch -m pytest -v -s && coverage report -m && coverage html
1313

1414
start:
15-
@test -d stage || mkdir stage
15+
@test -d files || mkdir files
1616
@.venv/bin/python3 app.py
1717

1818
lint:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The [default configuration](config.default.json) contains some base formats. To
6060

6161
- `title` (title of the webservice) is set to "Validation Service" by default.
6262
- `port` (numeric port to run the webservice) is set to 7007 by default.
63-
- `stage` (stage directory for data files at the server) is set to `false` (disabled) by default.
63+
- `files` (stage directory for data files at the server) is set to `false` (disabled) by default.
6464
- `reports` (reports directory to store reports in) is set to `false` (disabled) by default.
6565
- `downloads` (cache directory for data retrieved via URL) is set to `false` (disabled) by default.
6666

@@ -105,7 +105,7 @@ Validate data against an application profile and return a list of errors in [Dat
105105

106106
- `data` as string
107107
- `url` to be downloaded from an URL (if the service is configured with `downloads` directory)
108-
- `file` to be read from a local file in the stage directory of the server (if the service is configured with `stage` directory)
108+
- `file` to be read from a local file in the stage directory of the server (if the service is configured with `files` directory)
109109

110110
Status code is always 200 if validation could be executed, no matter whether errors have been found or not. For example validating the string `[1,2` at default profile `json` results in the following validation response. The error position (after the fourth character on line 1) is referenced with multiple dimensions. Dimension values are always strings.
111111

config.default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"port": 7007,
3-
"stage": false,
3+
"files": false,
44
"reports": false,
55
"downloads": false,
66
"profiles": [

lib/service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, config=None, **kwargs):
2121

2222
self.root = config.get("root", None)
2323

24-
for name in ['stage', 'reports', 'downloads']:
24+
for name in ['files', 'reports', 'downloads']:
2525
path = config.get(name, False)
2626
if path:
2727
path = Path(path)
@@ -63,12 +63,12 @@ def validate(self, profile, data=None, url=None, file=None):
6363
else:
6464
raise ValueError("This service does not support passing data via URL")
6565
else:
66-
if self.stage:
66+
if self.files:
6767
if not re.match('^[a-zA-Z0-9_-][a-z0-9._-]*$', file):
6868
raise ValueError("Filename must contain only characters [a-zA-Z0-9._-]")
69-
file = Path(self.stage / file)
69+
file = Path(self.files / file)
7070
if not file.is_file():
71-
raise LookupError(f"File not found in local stage: {file.name}")
71+
raise LookupError(f"File not found in local files: {file.name}")
7272
else:
7373
raise ValueError("This service does not support passing data at server")
7474

tests/test_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ def tmp_dir():
3434
def client(tmp_dir):
3535
app.testing = True
3636

37-
stage = Path(__file__).parent / 'files'
37+
files = Path(__file__).parent / 'files'
3838

3939
profiles = [{
4040
"id": "json",
4141
"checks": ["json"]
4242
}]
43-
init(dict(title="Validation Service Test", stage=stage, downloads=tmp_dir, profiles=profiles))
43+
init(dict(title="Validation Service Test", files=files, downloads=tmp_dir, profiles=profiles))
4444

4545
with app.test_client() as client:
4646
setattr(client, 'fail', lambda *args, **kw: expect_fail(client, *args, **kw))
4747
setattr(client, 'fine', lambda *args, **kw: expect_fine(client, *args, **kw))
48-
setattr(client, 'stage', stage)
48+
setattr(client, 'files', files)
4949
yield client
5050

5151

@@ -84,7 +84,7 @@ def test_validate_file(client):
8484
error="Filename must contain only characters [a-zA-Z0-9._-]")
8585

8686
client.fail('GET', '/json/validate?file=not.found', code=404,
87-
error="File not found in local stage: not.found")
87+
error="File not found in local files: not.found")
8888

8989
client.fine('GET', '/json/validate?file=valid.json')
9090

tests/test_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_config():
3636
service.validate('json', data=42)
3737

3838
with TemporaryDirectory() as path:
39-
service = ValidationService(stage=path, profiles=[])
39+
service = ValidationService(files=path, profiles=[])
4040

41-
with pytest.raises(FileNotFoundError, match=r"Missing stage directory:"):
42-
service = ValidationService(stage=f"{path}/XXX", profiles=[])
41+
with pytest.raises(FileNotFoundError, match=r"Missing files directory:"):
42+
service = ValidationService(files=f"{path}/XXX", profiles=[])
4343

4444
service = ValidationService(profiles=profiles, downloads=path)
4545

0 commit comments

Comments
 (0)