Example #1
0
 def _export_install_r_if_necessary(self) -> None:
     """Export an install.R file that can be used to install the same R packages and versions."""
     if self.history.packages.get("r"):
         install_r = export_install_r(r_packages=self.history.packages["r"])
         self.local_io.export_install_r(install_r)
     else:
         self.local_io.delete_install_r()
Example #2
0
def test_export_install_r_single_package():
    packages = Packages(
        Package(
            "jsonlite",
            'library("devtools"); install_version("jsonlite",version="1.6")'))
    actual = r.export_install_r(packages)
    expected = 'library("devtools"); install_version("jsonlite",version="1.6")'
    assert actual == expected
def test_export_install_r_multiple():
    custom_command_h2o = 'install.packages("h2o")'
    custom_command_trelliscopejs = (
        'library("devtools"); install_github("hafen/treslliscopejs")'
    )
    packages = {
        "h2o": Package("h2o", custom_command_h2o),
        "trelliscopejs": Package("trelliscopejs", custom_command_trelliscopejs),
    }
    actual = r.export_install_r(packages)
    expected = "\n".join([custom_command_h2o, custom_command_trelliscopejs])
    assert actual == expected
Example #4
0
def test_export_install_r_multiple_installs():
    packages = Packages([
        Package(
            "jsonlite",
            'library("devtools"); install_version("jsonlite",version="1.6")',
        ),
        Package(
            "praise",
            'library("devtools"); install_version("praise",version="1.0.0")',
        ),
    ])
    actual = r.export_install_r(packages)
    expected = "\n".join([
        'library("devtools"); install_version("jsonlite",version="1.6")',
        'library("devtools"); install_version("praise",version="1.0.0")',
    ])
    assert actual == expected
Example #5
0
def test_export_install_r_no_r_packages():
    actual = r.export_install_r(Packages())
    expected = ""
    assert actual == expected
def test_export_install_r():
    custom_command = 'install.packages("h2o")'
    packages = {"h2o": Package("h2o", custom_command)}
    actual = r.export_install_r(packages)
    expected = custom_command
    assert actual == expected