Exemplo n.º 1
0
def test_move_params():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = [
            'dmd', 'move', 'source', 'target', '-a', '-b', '-e', '-user',
            'baum'
        ]
        CommandLine().process()
Exemplo n.º 2
0
def test_move_nonvalid_params():
    with pytest.raises(SystemExit):
        sys.argv = [
            'dmd', 'move', 'source', 'basdasd', 'target', '-a', '-b', '-e',
            '-user', 'baum'
        ]
        CommandLine().process()
Exemplo n.º 3
0
def test_target_list(app,capfd):

        cookies = {
            'user': '******',
            'token': 'PZ151XH7A1'
            }

        body =  {
            'source': 'blablubb/blubb',
            'target': 'blablubb'
        }


        sys.argv = ['dmd', 'move', 'blablubb/blubb', 'blablubb']

        CommandLine().process()
        out,err = capfd.readouterr()

        assert out is '''{ 'job_id': 5 }'''

        subprocess.Popen.kill(app)
Exemplo n.º 4
0
def test_job_creation(flask_app, adapter,capfd):
    with patch('application_adapter.Application') as mock:
        adapter = mock.return_value
        adapter.create_job.return_value = json.dumps({ 'job_id': 5 })
        adapter.verify_user.return_value = 'Administrator'
        cookies = {
            'username': '******',
            'token': 'tokem1'
            },
        body = {
            'source': 'storage1',
            'target': 'storage2',
            }

        sys.argv = ['dmd', 'move', 'storage1', 'storage2']
        CommandLine().process()
        out,err = capfd.readouterr()

        adapter.verify_user.assert_called_once_with(json.dumps(cookies))
        adapter.create_job.assert_called_once_with(json.dumps(body))
        assert out == '{ \'job_id\': 5 }'
Exemplo n.º 5
0
def test_deactivate_nonvalid2(capfd):
    with pytest.raises(SystemExit):
        sys.argv = ['dmd', 'deactivate', 'storage']
        CommandLine().process()
        out, err = capfd.readouterr()
        assert out == 'Id for Storage or Worker needed'
Exemplo n.º 6
0
def test_deactivate_nonvalid(capfd):

    sys.argv = ['dmd', 'deactivate', 'A', '--id', '20']
    CommandLine().process()
    out, err = capfd.readouterr()
    assert out == 'Object A not known\n'
Exemplo n.º 7
0
def test_deactivate_storage():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'deactivate', 'storage', '--id', '20']
        CommandLine().process()
Exemplo n.º 8
0
def test_deactivate_master():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'deactivate', 'master']
        CommandLine().process()
Exemplo n.º 9
0
def test_workes():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'workers']
        CommandLine().process()
Exemplo n.º 10
0
def test_workes_nonvalid():
    with pytest.raises(SystemExit):
        sys.argv = ['dmd', 'workers', 'param']
        CommandLine().process()
Exemplo n.º 11
0
def test_activate_worker():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'activate', 'worker', '--id', '20']
        CommandLine().process()
Exemplo n.º 12
0
def test_move():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'move', 'source', 'target']
        CommandLine().process()
Exemplo n.º 13
0
def test_active_valid_noParams(capfd):
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'active']
        CommandLine().process()
Exemplo n.º 14
0
def test_cancel_notvalid(capfd):
    with pytest.raises(SystemExit):
        sys.argv = ['dmd', 'cancel', 'sadsaa']
        CommandLine().process()
Exemplo n.º 15
0
def test_cancel():
    with pytest.raises(requests.exceptions.ConnectionError):
        sys.argv = ['dmd', 'cancel', '20']
        CommandLine().process()
Exemplo n.º 16
0
def main(args=None):
    CommandLine().process()