Skip to content

Commit

Permalink
Enhance ubuntu 20 compatibility & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mab committed Jun 10, 2020
1 parent 329653a commit cc4b0b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
3 changes: 0 additions & 3 deletions pydiploy/require/python/utils.py
Expand Up @@ -7,7 +7,6 @@
import fabric
import fabtools
from fabric.api import env

from pydiploy.decorators import do_verbose
from pydiploy.require.system import shell

Expand Down Expand Up @@ -45,8 +44,6 @@ def python_pkg(update=False):
'python-dev'
if env.remote_python_version < 3
else 'python%s-dev' % env.remote_python_version,
'python3-dev',
'python-pip',
],
update=update,
)
Expand Down
1 change: 1 addition & 0 deletions pydiploy/require/python/virtualenv.py
Expand Up @@ -18,6 +18,7 @@ def virtualenv(clear=False):
use_sudo=True,
)
python_bin = '/usr/bin/python%s' % env.remote_python_version
# TODO: check if used on older python version !
# with shell("HOME=~%s %s" % (env.remote_owner, env.shell)):
fabtools.require.python.virtualenv(
env.remote_virtualenv_dir,
Expand Down
13 changes: 12 additions & 1 deletion tests/test_require_python.py
Expand Up @@ -37,9 +37,20 @@ def tearDown(self):
def test_python_pkg(self, dist_id, dist_rls, python_install, deb_packages):
python_pkg()
self.assertTrue(deb_packages.called)
self.assertEqual(deb_packages.call_args, call(['python-dev'], update=False))
self.assertTrue(python_install.called)
self.assertEqual(
deb_packages.call_args, call(['python-dev', 'python-pip'], update=False)
python_install.call_args, call('pip', upgrade=True, use_sudo=True)
)

@patch('fabtools.require.deb.packages', return_value=Mock())
@patch('fabtools.require.python.install', return_value=Mock())
@patch('fabtools.system.distrib_release', return_value='18')
@patch('fabtools.system.distrib_id', return_value='Ubuntu')
def test_python_ubuntu18_pkg(self, dist_id, dist_rls, python_install, deb_packages):
python_pkg()
self.assertTrue(deb_packages.called)
self.assertEqual(deb_packages.call_args, call(['python-dev'], update=False))
self.assertTrue(python_install.called)
self.assertEqual(
python_install.call_args, call('pip', upgrade=True, use_sudo=True)
Expand Down
8 changes: 5 additions & 3 deletions tools/pydiployfabfile.sublime-snippet
Expand Up @@ -9,6 +9,7 @@
from os.path import join
from fabric.api import env, execute, roles, task
from pydiploy.django import custom_manage_command as pydiploy_custom_command
from pydiploy.django import deploy_backend as pydiploy_deploy_backend
from pydiploy.django import deploy_frontend as pydiploy_deploy_frontend
Expand Down Expand Up @@ -39,7 +40,9 @@ env.root_package_name = 'myapp' # name of app in webapp
env.remote_home = '/home/django' # remote home root
env.remote_python_version = 3.4 # python version
env.remote_virtualenv_root = join(env.remote_home, '.virtualenvs') # venv root
env.remote_virtualenv_dir = join(env.remote_virtualenv_root, env.application_name) # venv for webapp dir
env.remote_virtualenv_dir = join(
env.remote_virtualenv_root, env.application_name
) # venv for webapp dir
env.remote_repo_url = 'git@git.net:myapp.git' # git repository url
env.local_tmp_dir = '/tmp' # tmp dir
env.remote_static_root = '/var/www/static' # root of static files
Expand Down Expand Up @@ -304,9 +307,8 @@ def custom_manage_cmd(cmd):
""" Execute custom command in manage.py """
execute(pydiploy_custom_command, cmd)
]]></content>
<description>Pydiploy fabfile 1.2.0</description>
<tabTrigger>pydiployfab</tabTrigger>
<scope>source.python</scope>
</snippet>
</snippet>

0 comments on commit cc4b0b1

Please sign in to comment.