<commit_before># -*- coding: utf-8 -*-

from couchapp import commands
from couchapp.errors import AppError

from mock import Mock, patch
from nose.tools import raises


@patch('couchapp.commands.document')
def test_init_dest(mock_doc):
    commands.init(None, None, '/tmp/mk')
    mock_doc.assert_called_once_with('/tmp/mk', create=True)


@patch('os.getcwd', return_value='/mock_dir')
@patch('couchapp.commands.document')
def test_init_dest_auto(mock_doc, mock_cwd):
    commands.init(None, None)
    mock_doc.assert_called_once_with('/mock_dir', create=True)


@raises(AppError)
@patch('os.getcwd', return_value=None)
@patch('couchapp.commands.document')
def test_init_dest_auto(mock_doc, mock_cwd):
    commands.init(None, None)<commit_msg>Test cases for push with export flag<commit_after># -*- coding: utf-8 -*-

from couchapp import commands
from couchapp.errors import AppError

from mock import Mock, patch
from nose.tools import raises


@patch('couchapp.commands.document')
def test_init_dest(mock_doc):
    commands.init(None, None, '/tmp/mk')
    mock_doc.assert_called_once_with('/tmp/mk', create=True)


@patch('os.getcwd', return_value='/mock_dir')
@patch('couchapp.commands.document')
def test_init_dest_auto(mock_doc, mock_cwd):
    commands.init(None, None)
    mock_doc.assert_called_once_with('/mock_dir', create=True)


@raises(AppError)
@patch('os.getcwd', return_value=None)
@patch('couchapp.commands.document')
def test_init_dest_none(mock_doc, mock_cwd):
    commands.init(None, None)


def test_push_outside():
    '''
    $ couchapp push /path/to/app
    '''
    pass


@patch('couchapp.commands.document', return_value='{"status": "ok"}')
def test_push_export_outside(mock_doc):
    '''
    $ couchapp push --export /path/to/app
    '''
    conf = Mock(name='conf')
    appdir = '/mock_dir'

    commands.push(conf, None, appdir, export=True)
    mock_doc.assert_called_once_with(appdir, create=False, docid=None)
    conf.update.assert_called_once_with(appdir)


@patch('couchapp.commands.document', return_value='{"status": "ok"}')
def test_push_export_inside(mock_doc):
    '''
    In the app dir::

    $ couchapp push --export
    '''
    conf = Mock(name='conf')
    appdir = '/mock_dir'

    commands.push(conf, appdir, export=True)
    mock_doc.assert_called_once_with(appdir, create=False, docid=None)
    conf.update.assert_called_once_with(appdir)
{'fraction_non_alphanumeric': 0.14207879295892709, 'fraction_numerical': 0.0008382229673093043, 'mean_word_length': 5.1048593350383635, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5683870', 'n_tokens_mistral': 843, 'n_tokens_neox': 826, 'n_words': 149}