"""Misc. tests that don't fit anywhere.

XXX: Try our best to reduce tests in this file.
"""

from pipenv.core import activate_virtualenv
from pipenv.project import Project


import pytest


@pytest.mark.code
@pytest.mark.install
@pytest.mark.skip(reason='non deterministic')
def test_code_import_manual(PipenvInstance):
    with PipenvInstance(chdir=True) as p:
        with open('t.py', 'w') as f:
            f.write('import requests')
        p.pipenv('install -c .')
        assert 'requests' in p.pipfile['packages']


@pytest.mark.code
@pytest.mark.virtualenv
@pytest.mark.project
def test_activate_virtualenv_no_source():
    command = activate_virtualenv(source=False)
    venv = Project().virtualenv_location
    assert command == '{0}/bin/activate'.format(venv)


@pytest.mark.lock
@pytest.mark.deploy
@pytest.mark.cli
def test_deploy_works(PipenvInstance, pypi):

    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
requests = "==2.14.0"
flask = "==0.12.2"
[dev-packages]
pytest = "==3.1.1"
            """.strip()
            f.write(contents)
        c = p.pipenv('install')
        assert c.return_code == 0
        c = p.pipenv('lock')
        assert c.return_code == 0
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
requests = "==2.14.0"
            """.strip()
            f.write(contents)

        c = p.pipenv('install --deploy')
        assert c.return_code > 0

@@ -1485,8 +1485,779 @@
 ode %3E 0%0A
+%0A%0A@pytest.mark.update%0A@pytest.mark.lock%0Adef test_update_locks(PipenvInstance, pypi):%0A%0A    with PipenvInstance(pypi=pypi) as p:%0A        c = p.pipenv('install requests==2.14.0')%0A        assert c.return_code == 0%0A        with open(p.pipfile_path, 'r') as fh:%0A            pipfile_contents = fh.read()%0A        pipfile_contents = pipfile_contents.replace('==2.14.0', '*')%0A        with open(p.pipfile_path, 'w') as fh:%0A            fh.write(pipfile_contents)%0A        c = p.pipenv('update requests')%0A        assert c.return_code == 0%0A        assert p.lockfile%5B'default'%5D%5B'requests'%5D%5B'version'%5D == '==2.18.4'%0A        c = p.pipenv('run pip freeze')%0A        assert c.return_code == 0%0A        lines = c.out.splitlines()%0A        assert 'requests==2.18.4' in %5Bl.strip() for l in lines%5D%0A

Add test to verify `pipenv update`