2019-07-11 10:51:34 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import nose
|
|
|
|
import os
|
2019-07-13 06:31:53 +02:00
|
|
|
import shutil
|
2019-07-11 10:51:34 +02:00
|
|
|
import sys
|
2019-07-13 06:31:53 +02:00
|
|
|
import tempfile
|
2019-07-11 10:51:34 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-07-13 06:31:53 +02:00
|
|
|
# test_directory is what we pass nose.run for where to find tests
|
2019-07-11 10:51:34 +02:00
|
|
|
test_directory = os.path.dirname(os.path.abspath(__file__))
|
2019-07-13 06:31:53 +02:00
|
|
|
|
|
|
|
# create a temporary directory to use for the application directory while running tests
|
|
|
|
temporary_application_directory = tempfile.mkdtemp('-elodie-tests')
|
|
|
|
os.environ['ELODIE_APPLICATION_DIRECTORY'] = temporary_application_directory
|
|
|
|
|
|
|
|
# copy config.ini-sample over to the test application directory
|
|
|
|
temporary_config_file_sample = '{}/config.ini-sample'.format(os.path.dirname(os.path.dirname(test_directory)))
|
|
|
|
temporary_config_file = '{}/config.ini'.format(temporary_application_directory)
|
|
|
|
shutil.copy2(
|
|
|
|
temporary_config_file_sample,
|
|
|
|
temporary_config_file,
|
|
|
|
)
|
|
|
|
|
|
|
|
# read the sample config file and store contents to be replaced
|
|
|
|
with open(temporary_config_file_sample, 'r') as f:
|
|
|
|
config_contents = f.read()
|
|
|
|
|
|
|
|
# set the mapquest key in the temporary config file and write it to the temporary application directory
|
|
|
|
config_contents = config_contents.replace('your-api-key-goes-here', 'x8wQLqGhW7qK3sFpjYtVTogVtoMK0S8s')
|
|
|
|
with open(temporary_config_file, 'w+') as f:
|
|
|
|
f.write(config_contents)
|
|
|
|
|
2019-07-11 10:51:34 +02:00
|
|
|
test_argv = sys.argv
|
|
|
|
test_argv.append('--verbosity=2')
|
|
|
|
result = nose.run(argv=test_argv)
|
|
|
|
if(result):
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
sys.exit(1)
|