Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #21 from ilgarm/master
Browse files Browse the repository at this point in the history
@esc I'll talk about the move @mriehl. It sounds like a good idea.
  • Loading branch information
Stefan Nordhausen committed Jun 23, 2016
2 parents 294b34b + 0c94b90 commit 71d28f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/main/python/pybuilder_aws_plugin/lambda_tasks.py
@@ -1,11 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import ast
import os
import subprocess
import zipfile

from pybuilder.core import depends, task
from pybuilder.plugins.python.distutils_plugin import build_install_dependencies_string

from .helpers import (upload_helper,
copy_helper,
Expand All @@ -27,14 +29,10 @@ def zip_recursive(archive, directory, folder=''):
folder=os.path.join(folder, item))


def as_pip_argument(dependency):
return "{0}{1}".format(dependency.name, dependency.version or "")


def prepare_dependencies_dir(logger, project, target_directory, excludes=None):
"""Get all dependencies from project and install them to given dir"""
excludes = excludes or []
dependencies = map(lambda dep: as_pip_argument(dep), project.dependencies)
dependencies = ast.literal_eval(build_install_dependencies_string(project))

index_url = project.get_property('install_dependencies_index_url')
if index_url:
Expand Down
9 changes: 0 additions & 9 deletions src/unittest/python/pybuilder_aws_plugin_tests.py
Expand Up @@ -206,25 +206,18 @@ def setUp(self):
self.mock_process = mock.Mock()
self.mock_process.returncode = 0
self.mock_popen.return_value = self.mock_process
self.patch_aspip = mock.patch(
'pybuilder_aws_plugin.lambda_tasks.as_pip_argument')
self.mock_aspip = self.patch_aspip.start()
self.mock_aspip.side_effect = lambda x: x.name
self.input_project = Project('.')
self.mock_logger = mock.Mock()

def tearDown(self):
self.patch_popen.stop()
self.patch_aspip.stop()

def test_prepare_dependencies_no_excludes(self):
"""Test prepare_dependencies_dir() w/o excludes."""
for dependency in ['a', 'b', 'c']:
self.input_project.depends_on(dependency)
prepare_dependencies_dir(
self.mock_logger, self.input_project, 'targetdir')
self.assertEqual(self.mock_aspip.call_count, 3)
self.assertNotEqual(self.mock_aspip.call_count, 4)
self.assertEqual(
list(self.mock_popen.call_args_list), [
mock.call(
Expand All @@ -248,8 +241,6 @@ def test_prepare_dependencies_with_excludes(self):
prepare_dependencies_dir(
self.mock_logger, self.input_project, 'targetdir',
excludes=['b', 'e', 'a'])
self.assertEqual(self.mock_aspip.call_count, 5)
self.assertNotEqual(self.mock_aspip.call_count, 4)
self.assertEqual(
list(self.mock_popen.call_args_list), [
mock.call(
Expand Down

0 comments on commit 71d28f5

Please sign in to comment.