Skip to content

Commit 8b08df9

Browse files
authored
fix: Adding more files to python_pip ignores (#27)
1 parent 6122a66 commit 8b08df9

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ init:
33

44
test:
55
# Run unit tests
6-
# Fail if coverage falls below 90%
7-
LAMBDA_BUILDERS_DEV=1 pytest --cov aws_lambda_builders --cov-report term-missing --cov-fail-under 90 tests/unit tests/functional
6+
# Fail if coverage falls below 94%
7+
LAMBDA_BUILDERS_DEV=1 pytest --cov aws_lambda_builders --cov-report term-missing --cov-fail-under 94 tests/unit tests/functional
88

99
func-test:
1010
LAMBDA_BUILDERS_DEV=1 pytest tests/functional

aws_lambda_builders/workflows/python_pip/workflow.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class PythonPipWorkflow(BaseWorkflow):
1818

1919
# Common source files to exclude from build artifacts output
2020
# Trimmed version of https://github.com/github/gitignore/blob/master/Python.gitignore
21-
EXCLUDED_FILES = (".git",
21+
EXCLUDED_FILES = (
22+
".aws-sam", ".chalice",
23+
24+
".git",
2225

2326
# Compiled files
2427
"*.pyc", "__pycache__", "*.so",

tests/functional/test_utils.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
import tempfile
3+
import shutil
4+
5+
from unittest import TestCase
6+
7+
from aws_lambda_builders.utils import copytree
8+
9+
class TestCopyTree(TestCase):
10+
11+
def setUp(self):
12+
self.source = tempfile.mkdtemp()
13+
self.dest = tempfile.mkdtemp()
14+
15+
def tearDown(self):
16+
shutil.rmtree(self.source)
17+
shutil.rmtree(self.dest)
18+
19+
def test_must_copy_files_recursively(self):
20+
file(self.source, "a", "file.txt")
21+
file(self.source, "a", "b", "file.txt")
22+
file(self.source, "a", "c", "file.txt")
23+
24+
copytree(self.source, self.dest)
25+
self.assertTrue(os.path.exists(os.path.join(self.dest, "a", "file.txt")))
26+
self.assertTrue(os.path.exists(os.path.join(self.dest, "a", "b", "file.txt")))
27+
self.assertTrue(os.path.exists(os.path.join(self.dest, "a", "c", "file.txt")))
28+
29+
def test_must_respect_excludes_list(self):
30+
file(self.source, ".git", "file.txt")
31+
file(self.source, "nested", ".aws-sam", "file.txt")
32+
file(self.source, "main.pyc")
33+
file(self.source, "a", "c", "file.txt")
34+
35+
excludes = [".git", ".aws-sam", "*.pyc"]
36+
37+
copytree(self.source, self.dest, ignore=shutil.ignore_patterns(*excludes))
38+
self.assertEquals(set(os.listdir(self.dest)), {"nested", "a"})
39+
self.assertEquals(set(os.listdir(os.path.join(self.dest, "nested"))), set())
40+
self.assertEquals(set(os.listdir(os.path.join(self.dest, "a"))), {"c"})
41+
self.assertEquals(set(os.listdir(os.path.join(self.dest, "a"))), {"c"})
42+
43+
def file(*args):
44+
path = os.path.join(*args)
45+
basedir = os.path.dirname(path)
46+
if not os.path.exists(basedir):
47+
os.makedirs(basedir)
48+
49+
# empty file
50+
open(path, 'a').close()

0 commit comments

Comments
 (0)