Esempio n. 1
0
def test_pushapps_export(discover_apps_, hook, document_, dumps):
    '''
    Test case for pushapps with ``--export``,

    Algo:
    1. discover apps
    #. pre-push
    #. add app to a list ``apps``
    #. post-push
    #. json.dumps from apps
    '''
    conf = NonCallableMock(name='conf')
    dest = None

    ret_code = commands.pushapps(conf, '/mock_dir', dest, export=True)

    assert ret_code == 0
    discover_apps_.assert_called_with('/mock_dir')
    hook.assert_any_call(conf, 'foo', 'pre-push',
                         dbs=conf.get_dbs(), pushapps=True)
    hook.assert_any_call(conf, 'foo', 'post-push',
                         dbs=conf.get_dbs(), pushapps=True)
    assert dumps.called
Esempio n. 2
0
def test_pushapps_output(discover_apps_, hook, document_, write_json):
    '''
    Test case for pushapps with ``--export --output file``

    Algo:
    1. discover apps
    #. pre-push
    #. add app to a list ``apps``
    #. post-push
    #. write_json(apps)
    '''
    conf = NonCallableMock(name='conf')
    dest = None

    ret_code = commands.pushapps(conf, '/mock_dir', dest, export=True, output='file')

    assert ret_code == 0
    discover_apps_.assert_called_with('/mock_dir')
    hook.assert_any_call(conf, 'foo', 'pre-push',
                         dbs=conf.get_dbs(), pushapps=True)
    hook.assert_any_call(conf, 'foo', 'post-push',
                         dbs=conf.get_dbs(), pushapps=True)
    'file' in write_json.call_args[0]
Esempio n. 3
0
def test_pushapps_noatomic(discover_apps_, hook, document_):
    '''
    Test case for pushapps with ``--no-atomic``

    Algo:
    1. discover apps

    #. for each app
        1. pre-push
        2. push
        3. post-push
    '''
    conf = NonCallableMock(name='conf')
    dest = 'http://localhost:5984'
    doc = document_()
    dbs = conf.get_dbs()

    ret_code = commands.pushapps(conf, '/mock_dir', dest, no_atomic=True)
    assert ret_code == 0
    conf.get_dbs.assert_called_with(dest)
    hook.assert_any_call(conf, 'foo', 'pre-push', dbs=dbs, pushapps=True)
    hook.assert_any_call(conf, 'foo', 'post-push', dbs=dbs, pushapps=True)
    doc.push.assert_called_with(dbs, True, False)