This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Updating config to auto search for the config directory This helps remove many arguments from the service installer functions * Adding POSTing feature for Zeppelin Notebook Now possible to POST notebooks to a running Zeppelin install * Removed a test accidentally on previous merge.
- Loading branch information
Showing
5 changed files
with
148 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,53 @@ | ||
import mock, unittest | ||
from env import scripts | ||
from scripts import config | ||
from ConfigParser import MissingSectionHeaderError | ||
|
||
def test_good_file(): | ||
params = config.read_config('res/good-test.properties') | ||
assert params['SECTION1']['key1'] == 'val1' | ||
assert params['SECTION2']['key2'] == 'val2' | ||
assert params['SECTION3']['key3'] == 'val3' | ||
assert params['SECTION3']['key4'] == 'val4' | ||
assert len(params['SECTION3']) > 1 | ||
assert len(params['SECTION2']) > 0 | ||
assert len(params['SECTION1']) > 0 | ||
assert len(params) == 3 | ||
|
||
def test_missing_header(): | ||
try: | ||
params = config.read_config('res/bad-test.properties') | ||
assert 0 | ||
except MissingSectionHeaderError as err: | ||
assert 1 | ||
|
||
def test_missing_file(): | ||
try: | ||
params = config.read_config('nofile') | ||
assert 0 | ||
except IOError as e: | ||
if 'could not find file' not in e.message: | ||
assert 0 | ||
class TestConfig(unittest.TestCase): | ||
|
||
@mock.patch('scripts.config.get_conf_dir', return_value='') | ||
def test_good_file(self, mock1): | ||
params = config.read_config('res/good-test.properties') | ||
assert params['SECTION1']['key1'] == 'val1' | ||
assert params['SECTION2']['key2'] == 'val2' | ||
assert params['SECTION3']['key3'] == 'val3' | ||
assert params['SECTION3']['key4'] == 'val4' | ||
assert len(params['SECTION3']) > 1 | ||
assert len(params['SECTION2']) > 0 | ||
assert len(params['SECTION1']) > 0 | ||
assert len(params) == 3 | ||
|
||
@mock.patch('scripts.config.get_conf_dir', return_value='') | ||
def test_missing_header(self, mock1): | ||
try: | ||
params = config.read_config('res/bad-test.properties') | ||
assert 0 | ||
except MissingSectionHeaderError as err: | ||
assert 1 | ||
|
||
@mock.patch('scripts.config.get_conf_dir', return_value='') | ||
def test_missing_file(self, mock1): | ||
try: | ||
params = config.read_config('nofile') | ||
assert 0 | ||
except IOError as e: | ||
if 'could not find file' not in e.message: | ||
assert 0 | ||
|
||
@mock.patch('os.path.exists', return_value=False) | ||
def test_bad_env(self, mock1): | ||
try: | ||
config.get_conf_dir() | ||
assert 0 | ||
except EnvironmentError as e: | ||
assert str(e) == 'Could not find conf directory' | ||
|
||
|
||
@mock.patch('os.path.exists', return_value=True) | ||
@mock.patch('os.getcwd', return_value='adir') | ||
def test_good_env(self, mock1, mock2): | ||
try: | ||
cdir = config.get_conf_dir() | ||
assert 'conf/' in cdir | ||
except EnvironmentError as e: | ||
assert str(e) == 'Could not find conf directory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters