|
1
|
|
|
# pylint: disable=unused-variable,expression-not-assigned,redefined-outer-name |
|
2
|
|
|
|
|
3
|
|
|
import sys |
|
4
|
|
|
|
|
5
|
|
|
import pytest |
|
6
|
|
|
import scripttest |
|
7
|
|
|
from expecter import expect |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
@pytest.fixture |
|
11
|
|
|
def env(tmpdir): |
|
12
|
|
|
path = str(tmpdir.join("test")) |
|
13
|
|
|
env = scripttest.TestFileEnvironment(path) |
|
14
|
|
|
return env |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
@pytest.fixture |
|
18
|
|
|
def cli(env): |
|
19
|
|
|
prog = sys.executable, '-m', 'osmerge' |
|
20
|
|
|
return lambda *args: env.run(*prog, *args, expect_error=True) |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
def describe_cli(): |
|
24
|
|
|
|
|
25
|
|
|
def it_displays_help_information(cli): |
|
26
|
|
|
cmd = cli('--help') |
|
27
|
|
|
|
|
28
|
|
|
expect(cmd.returncode) == 0 |
|
29
|
|
|
expect(cmd.stdout).contains("Usage: ") |
|
30
|
|
|
|
|
31
|
|
|
def it_displays_version_information(cli): |
|
32
|
|
|
cmd = cli('--version') |
|
33
|
|
|
|
|
34
|
|
|
expect(cmd.returncode) == 0 |
|
35
|
|
|
expect(cmd.stdout or cmd.stderr).contains("OSMerge v0.") |
|
36
|
|
|
|
|
37
|
|
|
def describe_new(): |
|
38
|
|
|
|
|
39
|
|
|
def it_generates_a_sample_project(cli): |
|
40
|
|
|
cmd = cli('new') |
|
41
|
|
|
|
|
42
|
|
|
expect(cmd.returncode) == 0 |
|
43
|
|
|
expect(sorted(cmd.files_created.keys())) == [ |
|
44
|
|
|
# TODO: figure out why .gitignore isn't showing up |
|
45
|
|
|
# ".gitignore", # ignore /tmp |
|
46
|
|
|
"Makefile", # builds the pipeline |
|
47
|
|
|
"docs", |
|
48
|
|
|
"docs/index.html", # example HTML file using `osmerge.geojson` |
|
49
|
|
|
"docs/osmerge.geojson", # converted from `tmp/merged.json` |
|
50
|
|
|
"osmerge.csv", # data set |
|
51
|
|
|
"osmerge.yml", # config file |
|
52
|
|
|
] |
|
53
|
|
|
|
|
54
|
|
|
def it_can_be_run_from_a_custom_root(cli): |
|
55
|
|
|
cmd = cli('new', '--root=foobar') |
|
56
|
|
|
|
|
57
|
|
|
expect(cmd.returncode) == 0 |
|
58
|
|
|
expect(cmd.files_created).contains("foobar/docs/index.html") |
|
59
|
|
|
|