Module: check_mk
Branch: master
Commit: 74f72daa28ef4996d576137f33499a0229685644
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=74f72daa28ef49…
Author: Roland Halbig <rh(a)mathias-kettner.de>
Date: Tue Jan 10 10:48:11 2017 +0100
Repaired table test.
Change-Id: I262c4a1ee55e76a52a6547fe0522cbc4dde35265
---
tests/web/test_table.py | 58 ++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/tests/web/test_table.py b/tests/web/test_table.py
index 7ce30e6..1590175 100644
--- a/tests/web/test_table.py
+++ b/tests/web/test_table.py
@@ -19,15 +19,12 @@ from tools import compare_html , gentest, compare_and_empty
from classes import DeprecatedRenderer
-try:
- from config.user import load_file, save_file
-except:
- load_file = lambda x, y: {}
- save_file = lambda x, y: None
-
+os.environ["OMD_SITE"] = "heute"
+import config
import table
-
import traceback
+def save_user_mock(name, data, user, unlock=False):
+ pass
class TableTest(html):
@@ -46,6 +43,31 @@ class TableTest(html):
self.written_text += " " * 4 * self.tag_counter + text +
''
+def test_table(monkeypatch):
+ monkeypatch.setattr(config, "save_user_file", save_user_mock)
+ table_test_cubical(False, False, None, 'html')
+
+
+def test_limit(monkeypatch):
+ monkeypatch.setattr(config, "save_user_file", save_user_mock)
+ table_test_cubical(False, False, 2, 'html')
+
+
+def test_sortable(monkeypatch):
+ monkeypatch.setattr(config, "save_user_file", save_user_mock)
+ table_test_cubical(True, False, None, 'html')
+
+
+def test_searchable(monkeypatch):
+ monkeypatch.setattr(config, "save_user_file", save_user_mock)
+ table_test_cubical(False, True, None, 'html')
+
+
+def test_csv(monkeypatch):
+ monkeypatch.setattr(config, "save_user_file", save_user_mock)
+ table_test_cubical(False, False, None, 'csv')
+
+
def read_out_table(text):
# Get the contents of the table as a list of lists
data = []
@@ -117,25 +139,3 @@ def table_test_cubical(sortable, searchable, limit, output_format):
assert len(data) == limit
assert data == rows[:limit]
-
-
-def test_table():
- table_test_cubical(False, False, None, 'html')
-
-
-def test_limit():
- table_test_cubical(False, False, 2, 'html')
-
-
-def test_sortable():
- table_test_cubical(True, False, None, 'html')
-
-
-def test_searchable():
- table_test_cubical(False, True, None, 'html')
-
-
-def test_csv():
- table_test_cubical(False, False, None, 'csv')
-
-