Exemple #1
0
def test_that_update_on_change_is_run_if_file_is_created(tmpdir):
    with batman_dir({
            "hash_dir": str(tmpdir),
            "update_on_change": {
                "monkey.txt": "touch bananas.txt"
            }
    }) as tmp_batman_dir:
        os.system('batman {0}'.format(tmp_batman_dir))
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        assert 'bananas.txt' in run('ls {0}'.format(tmp_batman_dir)).output
Exemple #2
0
def test_that_update_on_change_is_run_if_file_is_created(tmpdir):
    with batman_dir({
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "monkey.txt": "touch bananas.txt"
        }
    }) as tmp_batman_dir:
        os.system('batman {0}'.format(tmp_batman_dir))
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        assert 'bananas.txt' in run('ls {0}'.format(tmp_batman_dir)).output
Exemple #3
0
def test_that_virtualenv_is_created(tmpdir):
    TEST_PYTHON_FILENAME = '__batman_testfile.py'
    TEST_VIRTUALENV = '__batman_testenv'
    test_python_file = os.path.join(str(tmpdir), TEST_PYTHON_FILENAME)
    with batman_dir({
        "virtualenv": TEST_VIRTUALENV,
        "add2virtualenv": [str(tmpdir)],
    }) as tmp_batman_dir:
        touch_file(test_python_file)
        os.system('batman {0}'.format(tmp_batman_dir))
        output = TEST_PYTHON_FILENAME in run('lssitepackages', virtualenv=TEST_VIRTUALENV).output
    run("rmvirtualenv {0}".format(TEST_VIRTUALENV))
def test_that_on_update_commands_still_get_rerun_if_file_is_updated(tmpdir):
    test_yml = {
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "monkey.txt": "echo -ne '.' >> onedot.txt"
        }
    }
    with batman_dir(test_yml) as tmp_batman_dir:
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        run('echo -ne "updated" > monkey.txt', in_dir=tmp_batman_dir)
        os.system('batman {0}'.format(tmp_batman_dir))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '..'
Exemple #5
0
def test_that_on_update_commands_still_get_rerun_if_file_is_updated(tmpdir):
    test_yml = {
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "monkey.txt": "echo -ne '.' >> onedot.txt"
        }
    }
    with batman_dir(test_yml) as tmp_batman_dir:
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        run('echo -ne "updated" > monkey.txt', in_dir=tmp_batman_dir)
        os.system('batman {0}'.format(tmp_batman_dir))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '..'
Exemple #6
0
def test_that_virtualenv_is_created(tmpdir):
    TEST_PYTHON_FILENAME = '__batman_testfile.py'
    TEST_VIRTUALENV = '__batman_testenv'
    test_python_file = os.path.join(str(tmpdir), TEST_PYTHON_FILENAME)
    with batman_dir({
            "virtualenv": TEST_VIRTUALENV,
            "add2virtualenv": [str(tmpdir)],
    }) as tmp_batman_dir:
        touch_file(test_python_file)
        os.system('batman {0}'.format(tmp_batman_dir))
        output = TEST_PYTHON_FILENAME in run('lssitepackages',
                                             virtualenv=TEST_VIRTUALENV).output
    run("rmvirtualenv {0}".format(TEST_VIRTUALENV))
def test_wildcard_expansion(tmpdir):
    with batman_dir({
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "*/migrations/*": "echo -ne '.' >> onedot.txt"
        }
    }) as tmp_batman_dir:
        testpath = os.path.join(tmp_batman_dir, 'testapp', 'migrations')
        os.makedirs(testpath)
        os.system('batman {0}'.format(tmp_batman_dir))
        touch_file(os.path.join(testpath, 'imhere.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        run('echo "bleh" > {0}'.format(os.path.join(tmp_batman_dir, 'imhere.txt')))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '..'
Exemple #8
0
def test_wildcard_expansion(tmpdir):
    with batman_dir({
            "hash_dir": str(tmpdir),
            "update_on_change": {
                "*/migrations/*": "echo -ne '.' >> onedot.txt"
            }
    }) as tmp_batman_dir:
        testpath = os.path.join(tmp_batman_dir, 'testapp', 'migrations')
        os.makedirs(testpath)
        os.system('batman {0}'.format(tmp_batman_dir))
        touch_file(os.path.join(testpath, 'imhere.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        run('echo "bleh" > {0}'.format(
            os.path.join(tmp_batman_dir, 'imhere.txt')))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '..'
def test_that_on_update_commands_dont_get_rerun(tmpdir):
    """
    Should keep track of yaml stuff on a key-by-key basis and only rerun commands if
    that specific piece has changed.
    """
    test_yml = {
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "monkey.txt": "echo -ne '.' >> onedot.txt"
        }
    }
    with batman_dir(test_yml) as tmp_batman_dir:
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        test_yml['update_on_change']['walrus.txt'] = 'touch bucket.txt'
        update_batman_yml(tmp_batman_dir, test_yml)
        os.system('batman {0}'.format(tmp_batman_dir))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '.'
Exemple #10
0
def test_that_on_update_commands_dont_get_rerun(tmpdir):
    """
    Should keep track of yaml stuff on a key-by-key basis and only rerun commands if
    that specific piece has changed.
    """
    test_yml = {
        "hash_dir": str(tmpdir),
        "update_on_change": {
            "monkey.txt": "echo -ne '.' >> onedot.txt"
        }
    }
    with batman_dir(test_yml) as tmp_batman_dir:
        touch_file(os.path.join(tmp_batman_dir, 'monkey.txt'))
        os.system('batman {0}'.format(tmp_batman_dir))
        test_yml['update_on_change']['walrus.txt'] = 'touch bucket.txt'
        update_batman_yml(tmp_batman_dir, test_yml)
        os.system('batman {0}'.format(tmp_batman_dir))
        assert run('cat onedot.txt', in_dir=tmp_batman_dir).output == '.'
Exemple #11
0
def test_that_files_are_recursively_deleted():
    with batman_dir({'delete_pattern': "*.poop"}) as tmp_batman_dir:
        os.mkdir(os.path.join(tmp_batman_dir, 'something'))
        touch_file(os.path.join(tmp_batman_dir, 'something', 'deleteme.poop'))
        os.system('batman {0}'.format(tmp_batman_dir))
        assert 'deleteme' not in run('ls {0}'.format(tmp_batman_dir)).output
Exemple #12
0
def test_that_files_are_recursively_deleted():
    with batman_dir({'delete_pattern': "*.poop"}) as tmp_batman_dir:
        os.mkdir(os.path.join(tmp_batman_dir, 'something'))
        touch_file(os.path.join(tmp_batman_dir, 'something', 'deleteme.poop'))
        os.system('batman {0}'.format(tmp_batman_dir))
        assert 'deleteme' not in run('ls {0}'.format(tmp_batman_dir)).output