Module: check_mk
Branch: master
Commit: 4d4810e819c633b965ea87bad9988abde7e908f9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4d4810e819c633…
Author: Andreas Umbreit <au(a)mathias-kettner.de>
Date: Thu Jul 6 06:54:32 2017 +0200
Agent Updater Refactoring: Add first test cases for cmk-update-agent
- use pytest and pytest.mock framework
- add unit tests for HttpHandler and EnvironmentHandler
- add some component tests for registration and update scenarios
- simulate requests communication with saved files from real
communications
Change-Id: Icd49b408c0223552fba41a7479f51b7c17824574
---
.gitignore | 1 +
tests/requirements.txt | 2 ++
tests/testlib/__init__.py | 11 +++++++++++
3 files changed, 14 insertions(+)
diff --git a/.gitignore b/.gitignore
index ef3b8d2..6f604ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
.bugs/.last
.bugs/.my_ids
.cache
+.coverage
.directory
.metadata
.ropeproject
diff --git a/tests/requirements.txt b/tests/requirements.txt
index b6156ae..e31504c 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,4 +1,6 @@
pytest
+pytest-cov
+pytest-mock
requests
beautifulsoup4
pytest-stepwise
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 195c346..248dc6d 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -320,6 +320,17 @@ class Site(object):
return open(self.path(rel_path), "w").write(content)
+ def create_rel_symlink(self, link_rel_target, rel_link_name):
+ if not self._is_running_as_site_user():
+ p = self.execute(["ln", "-s", link_rel_target,
rel_link_name],
+ stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ p.communicate()
+ if p.wait() != 0:
+ raise Exception("Failed to create symlink from %s to ./%s.
Exit-Code: %d" % (rel_link_name, link_rel_target, p.wait()))
+ else:
+ return os.symlink(link_rel_target, os.path.join(self.root, rel_link_name))
+
+
def file_exists(self, rel_path):
if not self._is_running_as_site_user():
p = self.execute(["test", "-e", self.path(rel_path)],
stdout=subprocess.PIPE)