This commit is contained in:
		
							parent
							
								
									9ddb094ec7
								
							
						
					
					
						commit
						7fc5b5ffe0
					
				| @ -170,7 +170,7 @@ Usage: elodie.py verify | |||||||
| 
 | 
 | ||||||
| OK, so what if you don't like the folders being named `2015-07-Jul/Mountain View`? No problem! | OK, so what if you don't like the folders being named `2015-07-Jul/Mountain View`? No problem! | ||||||
| 
 | 
 | ||||||
| You can add a custom folder structure by editing your `config.ini` file (which should be placed under `~/.elodie/config.ini`). | You can add a custom folder structure by editing your `config.ini` file (which should be placed under `~/.elodie/config.ini`). If you'd like to use a different folder for your configuration file then set an environment variable named `ELODIE_APPLICATION_DIRECTORY` with the fully qualified directory path. | ||||||
| 
 | 
 | ||||||
| #### Custom folder examples | #### Custom folder examples | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,14 +2,20 @@ | |||||||
| Settings used by Elodie. | Settings used by Elodie. | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| from os import path | from os import environ, path | ||||||
| from sys import version_info | from sys import version_info | ||||||
| 
 | 
 | ||||||
| #: If True, debug messages will be printed. | #: If True, debug messages will be printed. | ||||||
| debug = False | debug = False | ||||||
| 
 | 
 | ||||||
| #: Directory in which to store Elodie settings. | #: Directory in which to store Elodie settings. | ||||||
| application_directory = '{}/.elodie'.format(path.expanduser('~')) | if ( | ||||||
|  |         'ELODIE_APPLICATION_DIRECTORY' in environ and | ||||||
|  |         path.isdir(environ['ELODIE_APPLICATION_DIRECTORY']) | ||||||
|  |    ): | ||||||
|  |     application_directory = environ['ELODIE_APPLICATION_DIRECTORY'] | ||||||
|  | else: | ||||||
|  |     application_directory = '{}/.elodie'.format(path.expanduser('~')) | ||||||
| 
 | 
 | ||||||
| #: File in which to store details about media Elodie has seen. | #: File in which to store details about media Elodie has seen. | ||||||
| hash_db = '{}/hash.json'.format(application_directory) | hash_db = '{}/hash.json'.format(application_directory) | ||||||
|  | |||||||
							
								
								
									
										68
									
								
								elodie/tests/constants_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								elodie/tests/constants_test.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,68 @@ | |||||||
|  | from __future__ import absolute_import | ||||||
|  | # Project imports | ||||||
|  | 
 | ||||||
|  | import os | ||||||
|  | import sys | ||||||
|  | import unittest  | ||||||
|  | 
 | ||||||
|  | try: | ||||||
|  |     reload  # Python 2.7 | ||||||
|  | except NameError: | ||||||
|  |     try: | ||||||
|  |         from importlib import reload  # Python 3.4+ | ||||||
|  |     except ImportError: | ||||||
|  |         from imp import reload  # Python 3.0 - 3.3 | ||||||
|  | 
 | ||||||
|  | from mock import patch | ||||||
|  | 
 | ||||||
|  | sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))) | ||||||
|  | 
 | ||||||
|  | from elodie import constants | ||||||
|  | 
 | ||||||
|  | BASE_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||||||
|  | 
 | ||||||
|  | def test_debug(): | ||||||
|  |     # This seems pointless but on Travis we explicitly modify the file to be True | ||||||
|  |     assert constants.debug == constants.debug, constants.debug | ||||||
|  | 
 | ||||||
|  | def test_application_directory_default(): | ||||||
|  |     reload(constants) | ||||||
|  |     expected_path = '{}/.elodie'.format(os.path.expanduser('~')) | ||||||
|  |     assert constants.application_directory == expected_path, constants.application_directory | ||||||
|  | 
 | ||||||
|  | def test_application_directory_override_invalid(): | ||||||
|  |     os.environ['ELODIE_APPLICATION_DIRECTORY'] = '/foo/bar' | ||||||
|  |     reload(constants) | ||||||
|  |     expected_path = '{}/.elodie'.format(os.path.expanduser('~')) | ||||||
|  |     assert constants.application_directory == expected_path, constants.application_directory | ||||||
|  | 
 | ||||||
|  | def test_application_directory_override_valid(): | ||||||
|  |     cwd = os.getcwd() | ||||||
|  |     os.environ['ELODIE_APPLICATION_DIRECTORY'] = cwd | ||||||
|  |     reload(constants) | ||||||
|  | 
 | ||||||
|  |     assert constants.application_directory == cwd, constants.application_directory | ||||||
|  |     assert cwd in constants.hash_db, constants.hash_db | ||||||
|  | 
 | ||||||
|  | # must come after test_application_directory_override_valid due to env var reset | ||||||
|  | def test_hash_db(): | ||||||
|  |     os.environ['ELODIE_APPLICATION_DIRECTORY'] = '' | ||||||
|  |     reload(constants) | ||||||
|  |     assert constants.hash_db == '{}/hash.json'.format(constants.application_directory), constants.hash_db | ||||||
|  | 
 | ||||||
|  | def test_location_db(): | ||||||
|  |     assert constants.location_db == '{}/location.json'.format(constants.application_directory), constants.location_db | ||||||
|  | 
 | ||||||
|  | def test_script_directory(): | ||||||
|  |     path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | ||||||
|  |     assert path == constants.script_directory, constants.script_directory | ||||||
|  | 
 | ||||||
|  | def test_exiftool_config(): | ||||||
|  |     path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | ||||||
|  |     assert '{}/configs/ExifTool_config'.format(path) == constants.exiftool_config, constants.exiftool_config | ||||||
|  | 
 | ||||||
|  | def test_accepted_language(): | ||||||
|  |     assert constants.accepted_language == 'en', constants.accepted_language | ||||||
|  | 
 | ||||||
|  | def test_python_version(): | ||||||
|  |     assert constants.python_version == sys.version_info.major, constants.python_version | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jaisen Mathai
						Jaisen Mathai