-
Notifications
You must be signed in to change notification settings - Fork 148
feat: allow path resolver to look at additional paths #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a92418b
bfad5a9
64d0c33
447dd81
7fbde18
c314ca9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,19 @@ | |
import tempfile | ||
import subprocess | ||
import copy | ||
import sys | ||
|
||
from unittest import TestCase | ||
from parameterized import parameterized | ||
|
||
try: | ||
import pathlib | ||
except ImportError: | ||
import pathlib2 as pathlib | ||
|
||
|
||
from aws_lambda_builders import RPC_PROTOCOL_VERSION as lambda_builders_protocol_version | ||
|
||
|
||
class TestCliWithHelloWorkflow(TestCase): | ||
|
||
|
@@ -39,19 +48,21 @@ def setUp(self): | |
def tearDown(self): | ||
shutil.rmtree(self.source_dir) | ||
shutil.rmtree(self.artifacts_dir) | ||
shutil.rmtree(self.scratch_dir) | ||
|
||
@parameterized.expand([ | ||
("request_through_stdin"), | ||
("request_through_argument") | ||
("request_through_stdin", lambda_builders_protocol_version), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test that fails compat check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes the test is present below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
("request_through_argument", lambda_builders_protocol_version), | ||
("request_through_stdin", "0.1"), | ||
("request_through_argument", "0.1"), | ||
]) | ||
def test_run_hello_workflow(self, flavor): | ||
def test_run_hello_workflow_with_backcompat(self, flavor, protocol_version): | ||
|
||
request_json = json.dumps({ | ||
"jsonschema": "2.0", | ||
"id": 1234, | ||
"method": "LambdaBuilder.build", | ||
"params": { | ||
"__protocol_version": protocol_version, | ||
"capability": { | ||
"language": self.language, | ||
"dependency_manager": self.dependency_manager, | ||
|
@@ -65,6 +76,7 @@ def test_run_hello_workflow(self, flavor): | |
"runtime": "ignored", | ||
"optimizations": {}, | ||
"options": {}, | ||
"executable_search_paths": [str(pathlib.Path(sys.executable).parent)] | ||
} | ||
}) | ||
|
||
|
@@ -94,4 +106,52 @@ def test_run_hello_workflow(self, flavor): | |
contents = fp.read() | ||
|
||
self.assertEquals(contents, self.expected_contents) | ||
shutil.rmtree(self.scratch_dir) | ||
|
||
@parameterized.expand([ | ||
("request_through_stdin"), | ||
("request_through_argument") | ||
]) | ||
def test_run_hello_workflow_incompatible(self, flavor): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is good for now, but it will need an upgrade when we change the version check logic or bump beyond 2.0. |
||
|
||
request_json = json.dumps({ | ||
"jsonschema": "2.0", | ||
"id": 1234, | ||
"method": "LambdaBuilder.build", | ||
"params": { | ||
"__protocol_version": "2.0", | ||
"capability": { | ||
"language": self.language, | ||
"dependency_manager": self.dependency_manager, | ||
"application_framework": self.application_framework | ||
}, | ||
"supported_workflows": [self.HELLO_WORKFLOW_MODULE], | ||
"source_dir": self.source_dir, | ||
"artifacts_dir": self.artifacts_dir, | ||
"scratch_dir": self.scratch_dir, | ||
"manifest_path": "/ignored", | ||
"runtime": "ignored", | ||
"optimizations": {}, | ||
"options": {}, | ||
"executable_search_paths": [str(pathlib.Path(sys.executable).parent)] | ||
} | ||
}) | ||
|
||
|
||
env = copy.deepcopy(os.environ) | ||
env["PYTHONPATH"] = self.python_path | ||
|
||
stdout_data = None | ||
if flavor == "request_through_stdin": | ||
p = subprocess.Popen([self.command_name], env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
stdout_data = p.communicate(input=request_json.encode('utf-8'))[0] | ||
elif flavor == "request_through_argument": | ||
p = subprocess.Popen([self.command_name, request_json], env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
stdout_data = p.communicate()[0] | ||
else: | ||
raise ValueError("Invalid test flavor") | ||
|
||
# Validate the response object. It should be error response | ||
response = json.loads(stdout_data) | ||
self.assertIn('error', response) | ||
self.assertEquals(response['error']['code'], 505) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this is some recent breaking change with gem