How to use install_version method in localstack

Best Python code snippet using localstack_python

test_r_end_to_end.py

Source:test_r_end_to_end.py Github

copy

Full Screen

...13 env = r_install(14 name=r_end_to_end_setup["name"],15 package_names=["jsonlite", "praise"],16 commands=[17 'library("devtools"); install_version("jsonlite", version="1.2")',18 'install.packages("praise")',19 ],20 yes=True,21 )22 r_end_to_end_setup["env"] = env23 return r_end_to_end_setup24@pytest.mark.run(order=-14)25def test_history_r_install(r_setup):26 """Test the history.yaml in detail."""27 # pylint: disable=line-too-long28 name = r_setup["name"]29 env = r_setup["env"]30 env_dir = r_setup["env_dir"]31 channels = r_setup["channels"]32 history_file = env_dir / "history.yaml"33 actual_history_content = history_file.read_text()34 print(actual_history_content)35 actual = yaml.load(actual_history_content, Loader=yaml.FullLoader)36 expected_packages = {37 "conda": {"r-base": "*", "r-devtools": "*"},38 "r": {39 "jsonlite": 'library("devtools"); install_version("jsonlite",version="1.2")',40 "praise": 'install.packages("praise")',41 },42 }43 expected_log = (44 r'R --quiet --vanilla -e "library(\"devtools\"); '45 r"install_version(\"jsonlite\",version=\"1.2\"); "46 r"install.packages(\"praise\")"47 )48 expected_action = (49 r'R --quiet --vanilla -e "library(\"devtools\"); '50 r"install_version(\"jsonlite\",version=\"1.2\",date=\"2019-01-01\"); "51 r'library(\"devtools\"); install_mran(\"praise\",version=\"1.0.0\",date=\"2019-01-01\")"'52 )53 expected_debug = 2 * [54 {55 "platform": get_platform_name(),56 "conda_version": CONDA_VERSION,57 "pip_version": pip.get_pip_version(name=name),58 "timestamp": str(date.today()),59 }60 ]61 assert actual["name"] == name62 assert actual["channels"] == channels63 assert actual["packages"] == expected_packages64 assert actual["revisions"][-1]["log"] == expected_log65 assert len(actual["revisions"]) == 266 assert actual["revisions"][-1]["action"] == expected_action67 for i in range(len(actual["revisions"])):68 for key, val in expected_debug[i].items():69 if key == "timestamp":70 assert actual["revisions"][i]["debug"][key].startswith(val)71 else:72 assert actual["revisions"][i]["debug"][key] == val73 dependencies = env.dependencies74 expected_history = [75 f"name: {name}",76 f"id: {env.history.id}",77 "history-file-version: '1.0'",78 "channels:",79 ]80 for channel in channels:81 expected_history.append(f" - {channel}")82 expected_history_start = "\n".join(83 expected_history84 + [85 "packages:",86 " conda:",87 " r-base: '*'",88 " r-devtools: '*'",89 " r:",90 ' jsonlite: library("devtools"); install_version("jsonlite",version="1.2")',91 ' praise: install.packages("praise")',92 "revisions:",93 " - packages:",94 " conda:",95 " r-base: '*'",96 " r-devtools: '*'",97 " diff:",98 " conda:",99 " upsert:",100 f" - r-base={dependencies['conda']['r-base'].version}",101 f" - r-devtools={dependencies['conda']['r-devtools'].version}",102 " log: conda create --name r_end_to_end_test r-base r-devtools --override-channels",103 " --strict-channel-priority --channel r",104 " --channel defaults",105 " action: conda create --name r_end_to_end_test r-base",106 ]107 )108 expected_second_revision = "\n".join(109 [110 " - packages:",111 " conda:",112 " r-base: '*'",113 " r-devtools: '*'",114 " r:",115 ' jsonlite: library("devtools"); install_version("jsonlite",version="1.2")',116 ' praise: install.packages("praise")',117 " diff:",118 " r:",119 " upsert:",120 f" - jsonlite",121 f" - praise",122 r' log: R --quiet --vanilla -e "library(\"devtools\"); install_version(\"jsonlite\",version=\"1.2\");',123 r" install.packages(\"praise\")",124 r' action: R --quiet --vanilla -e "library(\"devtools\"); install_version(\"jsonlite\",version=\"1.2\");',125 r" install.packages(\"praise\")",126 ]127 )128 index_first_action = actual_history_content.find(129 "action: conda create --name r_end_to_end_test r-base"130 ) + len("action: conda create --name r_end_to_end_test r-base")131 actual_history_start = actual_history_content[:index_first_action]132 assert actual_history_start == expected_history_start133 index_second_revision_start = actual_history_content.find(134 " - packages:", index_first_action135 )136 index_second_debug = actual_history_content.find(137 "debug:", index_second_revision_start138 )139 actual_second_revision = actual_history_content[140 index_second_revision_start:index_second_debug141 ].rstrip()142 assert actual_second_revision == expected_second_revision143@pytest.mark.run(order=-13)144def test_conda_env_yaml_r_install(r_setup):145 """Test the environment.yml file in detail."""146 name = r_setup["name"]147 env_dir = r_setup["env_dir"]148 channels = r_setup["channels"]149 packages = get_dependencies(name=name)150 conda_packages = packages["conda"]151 expected_start = [f"name: {name}", "channels:"]152 for channel in channels + ["nodefaults"]:153 expected_start.append(f" - {channel}")154 expected_start.append("dependencies:")155 expected_conda_packages = [156 " - r-base=" + conda_packages["r-base"].version,157 " - r-devtools=" + conda_packages["r-devtools"].version,158 ]159 expected = "\n".join(expected_start + expected_conda_packages) + "\n"160 actual = (env_dir / "environment.yml").read_text()161 print(actual)162 assert actual == expected163 install_r = "\n".join(164 [165 'library("devtools"); install_version("jsonlite", version="1.2")',166 'install.packages("praise")',167 ]168 )169 actual_install_r = (env_dir / "install.R").read_text()170 print(actual_install_r)171 assert actual_install_r == install_r172@pytest.mark.run(order=-12)173def test_r_remove_package(r_setup):174 # pylint: disable=too-many-locals175 name = r_setup["name"]176 env_dir = r_setup["env_dir"]177 channels = r_setup["channels"]178 r_remove(name=name, specs=["praise"], yes=True)179 history_file = env_dir / "history.yaml"180 actual_history_content = history_file.read_text()181 print(actual_history_content)182 expected_packages = {183 "conda": {"r-base": "*", "r-devtools": "*"},184 "r": {185 "jsonlite": 'library("devtools"); install_version("jsonlite", version="1.2")'186 },187 }188 actual = yaml.load(actual_history_content, Loader=yaml.FullLoader)189 remove_command = r"remove.packages(c(\"praise\"))"190 expected_log = f'R --quiet --vanilla -e "{remove_command}"'191 assert actual["packages"] == expected_packages192 assert actual["revisions"][-1]["log"] == expected_log193 assert actual["revisions"][-1]["action"] == expected_log194 packages = get_dependencies(name=name)195 conda_packages = packages["conda"]196 expected_start = [f"name: {name}", "channels:"]197 for channel in channels + ["nodefaults"]:198 expected_start.append(f" - {channel}")199 expected_start.append("dependencies:")200 expected_conda_packages = [201 " - r-base=" + conda_packages["r-base"].version,202 " - r-devtools=" + conda_packages["r-devtools"].version,203 ]204 expected = "\n".join(expected_start + expected_conda_packages) + "\n"205 actual = (env_dir / "environment.yml").read_text()206 print(actual)207 assert actual == expected208 install_r = "\n".join(209 ['library("devtools"); install_version("jsonlite", version="1.2")']210 )211 actual_install_r = (env_dir / "install.R").read_text()212 print(actual_install_r)213 assert actual_install_r == install_r214 expected_packages_section = "\n".join(215 [216 "packages:",217 " conda:",218 " r-base: '*'",219 " r-devtools: '*'",220 " r:",221 ' jsonlite: library("devtools"); install_version("jsonlite",version="1.2")',222 "revisions:",223 ]224 )225 assert expected_packages_section in actual_history_content226 expected_third_revision = "\n".join(227 [228 " - packages:",229 " conda:",230 " r-base: '*'",231 " r-devtools: '*'",232 " r:",233 ' jsonlite: library("devtools"); install_version("jsonlite",version="1.2")',234 " diff:",235 " r:",236 " remove:",237 " - praise",238 rf' log: R --quiet --vanilla -e "remove.packages(c(\"praise\"))"',239 rf' action: R --quiet --vanilla -e "remove.packages(c(\"praise\"))"',240 ]241 )242 index_first_revision = actual_history_content.find(" - packages:")243 index_second_revision = actual_history_content.find(244 " - packages:", index_first_revision + 1245 )246 index_third_revision = actual_history_content.find(247 " - packages:", index_second_revision + 1...

Full Screen

Full Screen

versions.py

Source:versions.py Github

copy

Full Screen

...163 raise ValueError(f"unknown version {version}")164 return engine_type, install_versions[version]165def get_engine_type(version: str) -> EngineType:166 return EngineType(version.split("_")[0])167def get_install_version(version: str) -> str:168 if version not in install_versions:169 raise ValueError(f"unknown version {version}")170 return install_versions[version]171def _opensearch_url(install_version: semver.VersionInfo) -> str:172 arch = "x64" if get_arch() == "amd64" else "arm64"173 version = str(install_version)174 return (175 f"https://artifacts.opensearch.org/releases/bundle/opensearch/"176 f"{version}/opensearch-{version}-linux-{arch}.tar.gz"177 )178def _es_url(install_version: semver.VersionInfo) -> str:179 arch = "x86_64" if get_arch() == "amd64" else "aarch64"180 version = str(install_version)181 repo = "https://artifacts.elastic.co/downloads/elasticsearch"...

Full Screen

Full Screen

test_r_gateways.py

Source:test_r_gateways.py Github

copy

Full Screen

...11)12def test_export_install_r_single_package():13 packages = Packages(14 Package(15 "jsonlite", 'library("devtools"); install_version("jsonlite",version="1.6")'16 )17 )18 actual = r.export_install_r(packages)19 expected = 'library("devtools"); install_version("jsonlite",version="1.6")'20 assert actual == expected21def test_export_install_r_multiple_packages():22 packages = Packages(23 [24 Package(25 "jsonlite",26 'library("devtools"); install_version("jsonlite",version="1.6")',27 ),28 Package(29 "praise",30 'library("devtools"); install_version("praise",version="1.0.0")',31 ),32 ]33 )34 actual = r.export_install_r(packages)35 expected = "\n".join(36 [37 'library("devtools"); install_version("jsonlite",version="1.6")',38 'library("devtools"); install_version("praise",version="1.0.0")',39 ]40 )41 assert actual == expected42def test_export_install_r_multiple_installs():43 packages = Packages(44 [45 Package(46 "jsonlite",47 'library("devtools"); install_version("jsonlite",version="1.6")',48 ),49 Package(50 "praise",51 'library("devtools"); install_version("praise",version="1.0.0")',52 ),53 ]54 )55 actual = r.export_install_r(packages)56 expected = "\n".join(57 [58 'library("devtools"); install_version("jsonlite",version="1.6")',59 'library("devtools"); install_version("praise",version="1.0.0")',60 ]61 )62 assert actual == expected63def test_export_install_r_no_r_packages():64 actual = r.export_install_r(Packages())65 expected = ""66 assert actual == expected67def test_parse_r_packages(mocker):68 stdout = f"""> {r.LIST_R_PACKAGES}69 Package Version70 checkpoint 0.4.571 jsonlite 1.672 praise 1.0.073 utf8 1.1.4...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful