示例#1
0
def test_read_config_no_rights():
    os.system('chmod a-r tests/test_utils_no_rights')
    if os.access('tests/test_utils_no_rights', os.R_OK):
        # running inside protected environment, cannot do this test
        assert True
    else:
        with nose.tools.assert_raises(Exception) as e:
            config.read_config('tests/test_utils_no_rights')
        os.system('chmod a+r tests/test_utils_no_rights')
        print e.exception
        nose.tools.ok_(
            str(e.exception) ==
            'File tests/test_utils_no_rights does not exist or is not readable',
            'File without read permissions should raise an exception')
示例#2
0
def test_read_config_list_ok():
    lst = config.read_config('tests/test_utils_cases').get('section_1',
                                                           None).get(
                                                               'list', None)
    print lst
    if len(lst) == 3:
        if lst[0] == 'value1' and lst[1] == '2' and lst[2] == 'value3':
            assert True
        else:
            assert False
    else:
        assert False
示例#3
0
def test_read_config_section_ok():
    assert config.read_config('tests/test_utils_cases').get(
        'section_1', None).get('key', None) == 'value'
示例#4
0
def test_read_config_section_empty():
    assert config.read_config('tests/test_utils_cases').get(
        'empty_section', None) == {}
示例#5
0
def test_read_config_positive():
    assert config.read_config('tests/test_utils_cases').get('key',
                                                            None) == 'value'
示例#6
0
def test_read_config_double_sign():
    assert config.read_config('tests/test_utils_cases').get(
        'double_sign', None) == 'value ='
示例#7
0
def test_read_config_no_value():
    assert config.read_config('tests/test_utils_cases').get('no_value',
                                                            None) is None
示例#8
0
def test_read_config_no_separator():
    res = config.read_config('tests/test_utils_cases').get(
        'no_separator', None)
    print res
    assert res is None
示例#9
0
def test_read_config_empty():
    with nose.tools.assert_raises(Exception) as e:
        config.read_config('tests/test_utils_empty')
    nose.tools.ok_(
        str(e.exception) == 'Empty configuration file tests/test_utils_empty',
        'Empty config file should raise an exception')
示例#10
0
def test_read_config_no_file():
    with nose.tools.assert_raises(Exception) as e:
        config.read_config('no_file')
    nose.tools.ok_(
        str(e.exception) == 'File no_file does not exist or is not readable',
        'Non-existent filename should raise an exception')
示例#11
0
def test_read_config_comments():
    # There is a set number of values in the cases file. The rest are negative scenarios and comments
    assert len(config.read_config('tests/test_utils_cases')) == 4