File: mapnik_config_test.py

package info (click to toggle)
mapnik 2.2.0%2Bds1-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,288 kB
  • ctags: 18,382
  • sloc: cpp: 115,128; python: 9,298; xml: 5,692; ansic: 3,726; makefile: 160; sh: 159; lisp: 13
file content (80 lines) | stat: -rw-r--r-- 2,495 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python

from nose.tools import *
from utilities import execution_path, run_all
from subprocess import Popen, PIPE, STDOUT
import os

import os, sys, glob, mapnik

def test_mapnik_config_no_args():
    process = Popen('mapnik-config', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    result = process.communicate()
    eq_('Usage: mapnik-config ' in result[0],True)
    eq_(result[1],'')
    eq_(process.returncode,1)

def test_mapnik_config_help():
    process = Popen('mapnik-config --help', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    result = process.communicate()
    eq_('Usage: mapnik-config ' in result[0],True)
    eq_(result[1],'')
    eq_(process.returncode,0)

def test_mapnik_config_help_short():
    process = Popen('mapnik-config -h', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    result = process.communicate()
    eq_('Usage: mapnik-config ' in result[0],True)
    eq_(result[1],'')
    eq_(process.returncode,0)

def test_mapnik_config_valid_opts():
    valid_args = [
      '-h',
      '--help',
      '-v',
      '--version',
      '--version-number',
      '--git-revision',
      '--git-describe',
      '--fonts',
      '--input-plugins',
      '--defines',
      '--prefix',
      '--lib-name',
      '--libs',
      '--dep-libs',
      '--ldflags',
      '--includes',
      '--dep-includes',
      '--cxxflags',
      '--cflags',
      '--all-flags',
      '--cxx'
    ]
    for item in valid_args:
        cmd = 'mapnik-config ' + item
        process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        result = process.communicate()
        eq_(process.returncode,0)
        eq_(len(result[0]) > 1,True,cmd)
        eq_(result[1],'')

def test_mapnik_config_invalid_option():
    cmd = 'mapnik-config --invalid-does-not-exist'
    process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    result = process.communicate()
    eq_(process.returncode,0)
    eq_(result[0].strip(),'')
    eq_(result[1].strip(),'unknown option --invalid-does-not-exist')

def test_mapnik_config_valid_and_invalid_option():
    cmd = 'mapnik-config --libs --invalid-does-not-exist'
    process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    result = process.communicate()
    eq_('mapnik' in result[0],True)
    eq_(result[1].strip(),'unknown option --invalid-does-not-exist')
    eq_(process.returncode,0)

if __name__ == "__main__":
    run_all(eval(x) for x in dir() if x.startswith("test_"))