def _test_unit_tests(self, code_directory: str): env = os.environ.copy() env["PYTHONPATH"] = "lib:." cmdlist = [self.python_executable, "-m", "pytest", "tests/unit"] LOG.info(cmdlist) result = run_command(cmdlist, self.cwd, env=env) self.assertNotIn("ERRORS", result.stdout)
def _test_build(self): cmdlist = [self.SAM_COMMAND, "build", "--debug"] if self.use_container: cmdlist.append("--use-container") LOG.info(cmdlist) result = run_command(cmdlist, self.cwd) self.assertIn("Build Succeeded", str(result.stdout))
def _test_local_invoke(self): events_path = Path(self.cwd, "events") if not events_path.exists(): LOG.info(f"Skip event testing, {events_path} does not exist") return event_files = os.listdir(events_path) for event_file in event_files: if self.function_id_by_event: cmdlist = [ "sam", "local", "invoke", self.function_id_by_event[event_file], "-e", Path("events", event_file), ] else: cmdlist = [ "sam", "local", "invoke", "-e", Path("events", event_file), ] LOG.info(cmdlist) result = run_command(cmdlist, self.cwd) try: self.invoke_output = json.loads(result.stdout) except json.decoder.JSONDecodeError: self.fail(f"Response is not a valid JSON: {result.stdout}")
def _test_unit_tests(self, code_directory: str): cmdlist = ["dotnet", "test"] LOG.info(cmdlist) LOG.info("Running in folder %s", self.cwd) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertEqual(result.process.returncode, 0) self.assertNotIn("Failed!", result.stdout)
def _test_unit_tests(self, code_directory: str): cmdlist = [ "npm", "test", ] LOG.info(cmdlist) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertIn("pass", result.stdout + result.stderr) self.assertNotIn("fail", result.stdout + result.stderr)
def _test_install(self, code_directory: str): cmdlist = ["ruby", "--version"] LOG.info(cmdlist) run_command(cmdlist, self.cwd) cmdlist = ["bundle", "install"] LOG.info(cmdlist) result = run_command(cmdlist, self.cwd) self.assertIn("Bundle complete!", result.stdout)
def _test_install(self, code_directory: str): cmdlist = [ "npm", "i", ] LOG.info(cmdlist) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertRegex( result.stdout, r"added \d+ packages from \d+ contributors and audited \d+ packages", ) self.assertIn( "found 0 vulnerabilities", result.stdout, )
def _test_install(self, code_directory: str): cmdlist = [ self.python_executable, "-m", "pip", "install", "-t", "lib", "-r", f"{code_directory}/requirements.txt", # to run pytest, pytest needs to be installed "pytest", "pytest-mock", ] LOG.info(cmdlist) result = run_command(cmdlist, self.cwd) if result.stdout: # when requirements.txt is empty, the stdout is also empty self.assertIn("Successfully installed", result.stdout)
def _test_unit_tests(self, code_directory: str): cmdlist = ["ruby", code_directory] LOG.info(cmdlist) result = run_command(cmdlist, self.cwd) self.assertIn("100% passed", result.stdout)
def _test_unit_tests(self, code_directory: str): cmdlist = ["go", "test", "-v"] LOG.info(cmdlist) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertIn("PASS", result.stdout) self.assertNotIn("FAIL", result.stdout)
def _test_unit_tests(self, code_directory: str): cmdlist = ["dotnet", "test"] LOG.info(cmdlist) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertIn("Passed", result.stdout) self.assertNotIn("Failed", result.stdout)
def _test_unit_tests(self, code_directory: str): cmdlist = ["mvn", "test"] LOG.info(cmdlist) result = run_command(cmdlist, Path(self.cwd, code_directory)) self.assertIn("BUILD SUCCESS", result.stdout)