Skip to content

Commit

Permalink
Make all tests offline #593 (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
athanikos authored and FabioRosado committed Jul 13, 2019
1 parent 0c7e0c0 commit 0ed98b0
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ def test_install_specific_local_git_module(self):
"repo": "https://github.com/rmccue/test-repository.git",
"branch": "master",
}
loader._install_module(config) # Clone remote repo for testing with
config["repo"] = os.path.join(config["install_path"], ".git")
config["repo"] = repo_path
config["install_path"] = os.path.join(
self._tmp_dir, "test_specific_local_module"
)
os.makedirs(repo_path)
with mock.patch("opsdroid.loader._LOGGER.debug"), mock.patch.object(
loader, "git_clone"
) as mockclone:
Expand Down Expand Up @@ -513,7 +513,7 @@ def test_install_specific_local_path_module(self):
"repo": "https://github.com/rmccue/test-repository.git",
"branch": "master",
}
loader._install_module(config) # Clone remote repo for testing with
os.makedirs(config["install_path"])
config["path"] = config["install_path"]
config["install_path"] = os.path.join(
self._tmp_dir, "test_specific_local_module"
Expand All @@ -533,13 +533,27 @@ def test_install_default_remote_module(self):
"install_path": os.path.join(self._tmp_dir, "test_default_remote_module"),
"branch": "master",
}
with mock.patch.object(loader, "pip_install_deps") as mockdeps:
loader._install_module(config)
self.assertLogs("_LOGGER", "debug")
mockdeps.assert_called_with(
os.path.join(config["install_path"], "requirements.txt")
)

with mock.patch("opsdroid.loader.Loader.git_clone") as mockclone:
with mock.patch.object(loader, "pip_install_deps") as mockdeps:
os.makedirs(config["install_path"])
mockclone.side_effect = shutil.copy(
"requirements.txt", config["install_path"]
)
loader._install_module(config)
self.assertLogs("_LOGGER", "debug")
mockdeps.assert_called_with(
os.path.join(config["install_path"], "requirements.txt")
)
mockclone.assert_called_with(
"https://github.com/opsdroid/"
+ config["type"]
+ "-"
+ config["name"]
+ ".git",
config["install_path"],
config["branch"],
)
shutil.rmtree(config["install_path"], onerror=del_rw)

def test_install_local_module_dir(self):
Expand Down

0 comments on commit 0ed98b0

Please sign in to comment.