Bertrand Chenal hace 7 años
padre
commit
3f1ba5e290
Se han modificado 6 ficheros con 34 adiciones y 0 borrados
  1. 0 0
      tests/__init__.py
  2. 9 0
      tests/base_test.py
  3. 12 0
      tests/conftest.py
  4. 5 0
      tests/network_only.yaml
  5. 3 0
      tests/pytest.ini
  6. 5 0
      tests/task_only.yaml

+ 0 - 0
tests/__init__.py


+ 9 - 0
tests/base_test.py

@@ -0,0 +1,9 @@
+from baker import base_cli, run_batch
+
+
+def test_all_conf(cfg):
+    cli = base_cli(['--dry-run'])
+    cli.cfg = cfg
+    import pdb;pdb.set_trace()
+    for task in cfg.tasks.values():
+        run_batch(task, [], cli)

+ 12 - 0
tests/conftest.py

@@ -0,0 +1,12 @@
+import glob
+
+from baker import load
+
+
+def pytest_generate_tests(metafunc):
+    if 'cfg' in metafunc.fixturenames:
+        configs = []
+        for name in glob.glob('tests/*yaml'):
+            cfg = load(name)
+            configs.append(cfg)
+        metafunc.parametrize("cfg", configs)

+ 5 - 0
tests/network_only.yaml

@@ -0,0 +1,5 @@
+networks:
+  web:
+    hosts:
+      - web1.example.com
+      - web2.example.com

+ 3 - 0
tests/pytest.ini

@@ -0,0 +1,3 @@
+[pytest]
+addopts = -s --tb=native --maxfail=1
+python_files = *_test.py

+ 5 - 0
tests/task_only.yaml

@@ -0,0 +1,5 @@
+tasks:
+  time:
+    desc: Print current time (on local machine)
+    local: date -Iseconds
+    once: true