Create a test runner script in python to run unit tests (#321)

This commit is contained in:
Jaisen Mathai 2019-07-11 01:51:34 -07:00 committed by GitHub
parent 032e24b204
commit 9e42edfa76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 3 deletions

View File

@ -11,8 +11,6 @@ before_install:
install: install:
- "pip install -r elodie/tests/requirements.txt" - "pip install -r elodie/tests/requirements.txt"
- "pip install coveralls" - "pip install coveralls"
# command to run tests
# test mapquest key
before_script: before_script:
- "mkdir ~/.elodie" - "mkdir ~/.elodie"
- "sed 's/your-api-key-goes-here/x8wQLqGhW7qK3sFpjYtVTogVtoMK0S8s/g' config.ini-sample > ~/.elodie/config.ini" - "sed 's/your-api-key-goes-here/x8wQLqGhW7qK3sFpjYtVTogVtoMK0S8s/g' config.ini-sample > ~/.elodie/config.ini"
@ -28,4 +26,4 @@ before_script:
after_success: after_success:
- "coveralls" - "coveralls"
script: script:
- "nosetests --with-coverage --cover-package=elodie -w elodie/tests" - "./elodie/tests/run_tests.py -w elodie/tests --with-coverage --cover-package=elodie"

View File

@ -605,6 +605,44 @@ def test_verify_error():
assert origin in result.output, result.output assert origin in result.output, result.output
assert 'Error 1' in result.output, result.output assert 'Error 1' in result.output, result.output
# @mock.patch('elodie.config.config_file', '%s/config.ini-cli-batch-plugin-googlephotos' % gettempdir())
# def test_cli_batch_plugin_googlephotos():
# auth_file = helper.get_file('plugins/googlephotos/auth_file.json')
# secrets_file = helper.get_file('plugins/googlephotos/secrets_file.json')
# config_string = """
# [Plugins]
# plugins=GooglePhotos
# [PluginGooglePhotos]
# auth_file={}
# secrets_file={}
# """
# config_string_fmt = config_string.format(
# auth_file,
# secrets_file
# )
# with open('%s/config.ini-cli-batch-plugin-googlephotos' % gettempdir(), 'w') as f:
# f.write(config_string_fmt)
# if hasattr(load_config, 'config'):
# del load_config.config
# final_file_path_1 = helper.get_file('plain.jpg')
# final_file_path_2 = helper.get_file('no-exif.jpg')
# sample_metadata_1 = Photo(final_file_path_1).get_metadata()
# sample_metadata_2 = Photo(final_file_path_2).get_metadata()
# gp = GooglePhotos()
# gp.after('', '', final_file_path_1, sample_metadata_1)
# gp.after('', '', final_file_path_2, sample_metadata_1)
# if hasattr(load_config, 'config'):
# del load_config.config
# runner = CliRunner()
# result = runner.invoke(elodie._batch)
# assert "elodie/elodie/tests/files/plain.jpg uploaded successfully.\"}\n" in result.output, result.output
# assert "elodie/elodie/tests/files/no-exif.jpg uploaded successfully.\"}\n" in result.output, result.output
def test_cli_debug_import(): def test_cli_debug_import():
runner = CliRunner() runner = CliRunner()
# import # import

15
elodie/tests/run_tests.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
import nose
import os
import sys
if __name__ == "__main__":
test_directory = os.path.dirname(os.path.abspath(__file__))
test_argv = sys.argv
test_argv.append('--verbosity=2')
result = nose.run(argv=test_argv)
if(result):
sys.exit(0)
else:
sys.exit(1)