def test_empty_mysqladmin_var(): with pytest.raises(ParseException) as e_info: MysqladminVars(context_wrap(INPUT_EMPTY)) assert "Empty or wrong content in table." in str(e_info.value) with pytest.raises(ParseException) as e_info: MysqladminVars(context_wrap(INPUT_FORAMT_WRONG)) assert "Unparseable line in table" in str(e_info.value)
def test_mysqladmin_still_parsable(): res = MysqladminVars(context_wrap(INPUT_STILL_PARSABLE_1)) d = res.data assert d['aria_checkpoint_interval'] == '30 | 23' res = MysqladminVars(context_wrap(INPUT_STILL_PARSABLE_2)) d = res.data assert d['ft_boolean_syntax'] == '+ -><()~*:""&|' res = MysqladminVars(context_wrap(INPUT_FORAMT_WRONG)) assert len(res.bad_lines) == 3 assert res.bad_lines[ 1] == '| version_compile_machine | x86_64 |x'
def test_mysqladmin_vars(): res = MysqladminVars(context_wrap(INPUT_NORMAL)) d = res.data assert len(list(d)) == 14 assert d['version_comment'] == 'MariaDB Server' assert d['datadir'] == '/var/lib/mysql/' assert d['auto_increment_increment'] == '1' assert d.get('abc') is None assert res.get('abc', '233') == '233' assert res.get('init_file') == '' assert res.get('wait_what') is None assert res.get('wait_timeout') == '28800' assert res.getint('wait_timeout') == 28800 assert res.getint('version_compile_machine') is None assert res.get('binlog_stmt_cache_size', '666') == '32768' with pytest.raises(TypeError) as e_info: res.getint('binlog_stmt_cache_size', '666') assert "Default value should be int type." in str(e_info.value)
def test_doc(): env = { 'MysqladminStatus': MysqladminStatus, 'result': MysqladminStatus( context_wrap(OUTPUT_MYSQLADMIN_STATUS, path='/bin/mysqladmin status')), 'MysqladminVars': MysqladminVars, 'output': MysqladminVars(context_wrap(INPUT_NORMAL, '/bin/mysqladmin variables')), } failed, total = doctest.testmod(mysqladmin, globs=env) assert failed == 0
def test_wrong_mysqladmin_var(): with pytest.raises(ParseException) as e_info: MysqladminVars(context_wrap(INPUT_EMPTY)) assert "Variable_name" in str(e_info.value)
def test_empty_mysqladmin_var(): with pytest.raises(SkipException) as e_info: MysqladminVars(context_wrap("")) assert "Empty content." in str(e_info.value)