Permalink
Browse files

House keeping - fix broken test

  • Loading branch information...
ferrouswheel committed Mar 19, 2013
1 parent 8ea1fa3 commit 700552d53d1d854081a2323ddb7ffa99073178b2
Showing with 50 additions and 53 deletions.
  1. +4 −0 .gitignore
  2. +22 −25 README.md
  3. +8 −14 TESTING
  4. +9 −7 mdig/mdig/config.py
  5. +1 −4 mdig/mdig/grass.py
  6. +1 −0 mdig/mdig/tests/__init__.py
  7. +1 −1 mdig/mdig/tests/mdig.conf
  8. +4 −2 requirements.txt
View
@@ -23,3 +23,7 @@ test/repository/variables/model.xml.bak1
test/repository/variables/model.xml.bak2
../test/grass_location/PERMANENT/.bashrc
*.pyc
grass-modules/**/*.tmp.html
grass-modules/**/OBJ*
*.swp
*.un~
View
@@ -1,36 +1,27 @@
# MDiG - Modular Dispersal in GIS
# mdig - Modular Dispersal in GIS
## Requirements
## Setup
- [**GRASS 6.4RC5**](http://grass.itc.it/download/index.php) or later, hasn't been tested with the new GRASS 7.0.
In particular, we recommend an SVN snapshot as RC5 has an annoying
g.region issue that can be confusing for new users.
- [**GDAL 1.6.0**](http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries) or later (earlier versions have bugs)
Although it is a GRASS requirement instead of a direct MDiG one, stuff can
break if you have earlier buggy versions.
- ImageMagick's convert utility (imagemagick)
- [lxml](http://codespeak.net/lxml/) and its dependency, the [Gnome XML library](http://xmlsoft.org/)
- GNU Scientific Library (libgsl, libgsl0-dev) http://www.gnu.org/software/gsl/
sudo apt-get install \
gsl-bin libgsl0-dev bc libxml2 libxml2-dev python-lxml python-imaging-tk \
python-scipy python-matplotlib python-numpy python-configobj python-paste \
python-simplejson imagemagick
- Python dependencies
sudo apt-get install grass grass-dev
sudo apt-get install libxml2 libxml2-dev gsl-bin libgsl0-dev imagemagick bc
# Numpy and scipy are potentially finicky, so safest to install them separate
# and in order:
mkvirtualenv mdig
pip install numpy
pip install scipy
# Rest of python dependencies should be fine, ensure you are in mdig root dir
pip install -r requirements.txt
## Compile modules
That's the core mdig simulation manager, but to install the custom GRASS
modules that are particularly useful for people modelling dispersal:
Change into MDiG's grass-module dir
cd grass-modules
sudo make MODULE_TOPDIR=/usr/lib/grass64
cd mdig/grass-modules
Or if you installed GRASS from source, you can do something like:
and run:
export GRASS_SRC=~/src/grass63_release
export GRASS_SRC=~/src/grass64_release
make -S MODULE_TOPDIR=$GRASS_SRC
cd $GRASS_SRC
make install
@@ -41,3 +32,9 @@ These are the requests that I've had for MDiG to support:
* [PRIORITY] Keep track of area treated by management strategies.
## Troubleshooting
Older versions of requirements have some bugs to be aware of:
* GRASS 6.4RC5 has an annoying g.region issue that can be confusing for new users.
* GDAL <1.6.0 or later, earlier versions can run into segfaults.
View
22 TESTING
@@ -1,25 +1,19 @@
If you wish to run the unit tests for MDiG while developing code, then install
nosetests for python which is a testing framework, and optionally "coverage"
which is to measure the code coverage of tests:
If you wish to run the unit tests for MDiG while developing code, then go to
the mdig program directory ('mdig/' from the root of the source) and run:
easy_install nose coverage paste
Then if you go to the mdig program directory (mdig/ from the root of the source)
and run:
nosetests -v
nosetests -v
Or to run with code coverage analysis:
nosetests -v --with-coverage
nosetests -v --with-coverage
You'll run a bunch of tests to check everything's working correctly.
Note - currently only basic tests are run, more rigarous tests are
needed (although this has been greatly improved over the last year):
* More model files that more thoroughly test the potential model types.
Note - currently only basic tests are run, more rigorous tests are needed
(although this has been greatly improved over the last year):
* Additional model files that more thoroughly test the potential model types.
* More coverage in unit tests for components within MDiG.
* Comparison of the output maps from various models versus what the expected map
should look like. For modules, create before and after maps and make sure they
have no difference,implement as a shell script to be run within GRASS.
View
@@ -102,18 +102,20 @@ def find_grass_base_dir():
opts = glob.glob(os.path.join(os.environ['OSGEO4W_ROOT'],'apps\\grass\\grass-*'))
else:
opts = glob.glob('/usr/local/grass-*')
if len(opts) > 0: return opts[-1]
else: return None
opts.extend(glob.glob('/usr/lib/grass*'))
if len(opts) > 0:
return opts[-1]
def find_grassdb_dir():
# TODO find from GRASS environment if it exists
# find from guessing /home/user/src/mdig/test
my_path = os.path.normpath(os.path.join(home_dir, '..', 'src/mdig/test'))
if os.path.isdir(my_path): return my_path
if os.path.isdir(my_path):
return my_path
if 'OSGEO4W_ROOT' in os.environ:
my_path = os.path.normpath(os.path.join(os.environ['OSGEO4W_ROOT'], 'src/mdig/test'))
if os.path.isdir(my_path): return my_path
return None
if os.path.isdir(my_path):
return my_path
def find_location_dir():
# TODO find from GRASS environment if it exists
@@ -127,7 +129,6 @@ def find_location_dir():
if os.path.isdir(d) and \
os.path.isdir(os.path.join(d,'PERMANENT')):
return os.path.basename(d)
return None
class MDiGConfig(ConfigObj):
@@ -311,7 +312,8 @@ def prompt_for_config(self,section,k,fresh):
if section in MDiGConfig.required \
and k in MDiGConfig.required[section]:
guess = MDiGConfig.required[section][k]
if guess: guess = guess() # guess should be a callable
if guess:
guess = guess() # guess should be a callable
if not fresh:
print "While setting up config, required parameter %s:%s was missing" % (section,k)
is_done = False
View
@@ -24,8 +24,6 @@
import logging
import random
import re
import signal
import pdb
import subprocess
from subprocess import Popen
import StringIO
@@ -251,7 +249,6 @@ def init_pid_specific_files(self):
os.environ["GISRC"]=gisrc_fn
def get_version_from_dir(self):
import re
if sys.platform == 'win32':
# TODO - place this in config and make NSIS script write it
self.grass_version = "6.4.0svn"
@@ -260,7 +257,7 @@ def get_version_from_dir(self):
try:
x=re.match(r'grass-(\d\.\d\.[\d\w]+)', end_bit)
self.grass_version = x.groups()[0]
except IndexError, e:
except (IndexError, AttributeError):
self.grass_version = "6.4.0svn"
return self.grass_version
@@ -19,6 +19,7 @@ def setup():
# Copy test repository
c = config.get_config()
c['GRASS']['GISBASE'] = config.find_grass_base_dir()
assert c['GRASS']['GISBASE'], "Couldn't find GRASS GISBASE"
global test_dir
test_dir = tempfile.mkdtemp(prefix="mdig_test_")
end_part = os.path.split(c['GRASS']['GISDBASE'])[1]
@@ -8,7 +8,7 @@ GRASS_HTML_BROWSER = firefox
GRASS_MESSAGE_FORMAT = silent
GRASS_GNUPLOT = gnuplot -persist
MAPSET = PERMANENT
GISBASE = c:\\mdig
GISBASE = /usr/lib/grass64
GISDBASE = ../test
GRASS_TRUECOLOR = TRUE
GRASS_PAGER = cat
View
@@ -5,6 +5,8 @@ python-dateutil<2.0
numpy
scipy
matplotlib
imagetk
pillow
nose
coverage
paste
mock

0 comments on commit 700552d

Please sign in to comment.