Passed
Push — master ( 7fc5b5...19be12 )
by Jaisen
01:44
created

elodie/tests/constants_test.py (4 issues)

Check for undefined variables.

Best Practice Comprehensibility Minor
1
from __future__ import absolute_import
2
# Project imports
3
4
import os
5
import sys
6
import unittest 
7
8
try:
9
    reload  # Python 2.7
10
except NameError:
11
    try:
12
        from importlib import reload  # Python 3.4+
13
    except ImportError:
14
        from imp import reload  # Python 3.0 - 3.3
15
16
from mock import patch
17
18
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
19
20
from elodie import constants
21
22
BASE_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
23
24
def test_debug():
25
    # This seems pointless but on Travis we explicitly modify the file to be True
26
    assert constants.debug == constants.debug, constants.debug
27
28
def test_application_directory_default():
29
    reload(constants)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable reload does not seem to be defined.
Loading history...
30
    expected_path = '{}/.elodie'.format(os.path.expanduser('~'))
31
    assert constants.application_directory == expected_path, constants.application_directory
32
33
def test_application_directory_override_invalid():
34
    os.environ['ELODIE_APPLICATION_DIRECTORY'] = '/foo/bar'
35
    reload(constants)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable reload does not seem to be defined.
Loading history...
36
    expected_path = '{}/.elodie'.format(os.path.expanduser('~'))
37
    assert constants.application_directory == expected_path, constants.application_directory
38
39
def test_application_directory_override_valid():
40
    cwd = os.getcwd()
41
    os.environ['ELODIE_APPLICATION_DIRECTORY'] = cwd
42
    reload(constants)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable reload does not seem to be defined.
Loading history...
43
44
    assert constants.application_directory == cwd, constants.application_directory
45
    assert cwd in constants.hash_db, constants.hash_db
46
47
# must come after test_application_directory_override_valid due to env var reset
48
def test_hash_db():
49
    os.environ['ELODIE_APPLICATION_DIRECTORY'] = ''
50
    reload(constants)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable reload does not seem to be defined.
Loading history...
51
    assert constants.hash_db == '{}/hash.json'.format(constants.application_directory), constants.hash_db
52
53
def test_location_db():
54
    assert constants.location_db == '{}/location.json'.format(constants.application_directory), constants.location_db
55
56
def test_script_directory():
57
    path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
58
    assert path == constants.script_directory, constants.script_directory
59
60
def test_exiftool_config():
61
    path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
62
    assert '{}/configs/ExifTool_config'.format(path) == constants.exiftool_config, constants.exiftool_config
63
64
def test_accepted_language():
65
    assert constants.accepted_language == 'en', constants.accepted_language
66
67
def test_python_version():
68
    assert constants.python_version == sys.version_info.major, constants.python_version
69