Example #1
0
def test_dbinit_typical_case_returns_zero(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write(TEMP_CONFIG)
        tf.flush()
        args = ['dbinit', '--no-confirm', '-f', tf.name]
        ret = dosocs2.main(args)
        assert ret == 0
Example #2
0
def test_dbinit_warning_includes_connection_uri(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write(TEMP_CONFIG)
        tf.flush()
        args = ['dbinit', '--no-confirm', '-f', tf.name]
        ret = dosocs2.main(args)
        out, err = capsys.readouterr()
        assert 'sqlite:///:memory:' in err
Example #3
0
def test_configtest_expected_output_typical_case(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write('''
connection_uri = sqlite:///:memory:
namespace_prefix = sqlite:///:memory:
scanner_nomos_path = /dev/null
''')
        tf.flush()
        expected = '''
-------------------------------------------------------------------------------

Config location:
{}

-------------------------------------------------------------------------------

Effective configuration:

# begin dosocs2 config

connection_uri = sqlite:///:memory:
default_scanners = nomos
echo = False
namespace_prefix = sqlite:///:memory:
scanner_nomos_path = /dev/null

# end dosocs2 config

-------------------------------------------------------------------------------

Testing specified scanner paths...
nomos (/dev/null)...ok.

-------------------------------------------------------------------------------

Testing database connection...ok.
'''.format(tf.name)
        args = [
            'configtest', 
            '-f',
            tf.name
            ]
        dosocs2.main(args)
    out, err = capsys.readouterr()
    assert out == expected
Example #4
0
def test_configtest_expected_output_typical_case(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write('''
connection_uri = sqlite:///:memory:
namespace_prefix = sqlite:///:memory:
scanner_nomos_path = /dev/null
''')
        tf.flush()
        expected = '''
-------------------------------------------------------------------------------

Config location:
{}

-------------------------------------------------------------------------------

Effective configuration:

# begin dosocs2 config

connection_uri = sqlite:///:memory:
default_scanners = nomos
echo = False
namespace_prefix = sqlite:///:memory:
scanner_nomos_path = /dev/null

# end dosocs2 config

-------------------------------------------------------------------------------

Testing specified scanner paths...
nomos (/dev/null)...ok.

-------------------------------------------------------------------------------

Testing database connection...ok.
'''.format(tf.name)
        args = ['configtest', '-f', tf.name]
        dosocs2.main(args)
    out, err = capsys.readouterr()
    assert out == expected
Example #5
0
def test_dbinit_typical_case_returns_zero(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write(TEMP_CONFIG)
        tf.flush()
        args = [
            'dbinit', 
            '--no-confirm',
            '-f',
            tf.name
            ]
        ret = dosocs2.main(args)
        assert ret == 0
Example #6
0
def test_dbinit_warning_includes_connection_uri(capsys):
    with NamedTemporaryFile(mode='w+') as tf:
        tf.write(TEMP_CONFIG)
        tf.flush()
        args = [
            'dbinit', 
            '--no-confirm',
            '-f',
            tf.name
            ]
        ret = dosocs2.main(args)
        out, err = capsys.readouterr()
        assert 'sqlite:///:memory:' in err
Example #7
0
def run_dosocs2(args):
    return dosocs2.main(args)