Ejemplo n.º 1
0
def test_parses_a_whole_config_correctly(monkeypatch):
    sleep_mock = MagicMock()
    monkeypatch.setattr("time.sleep", sleep_mock)
    filename = pkg_resources.resource_filename("tests.policy", "example_config2.yml")
    policy = PolicyRunner.validate_file(filename)
    inventory = MagicMock()
    k8s_inventory = MagicMock()
    driver = MagicMock()
    executor = MagicMock()
    LOOPS = 1000
    nodes, pods = PolicyRunner.run(policy, inventory, k8s_inventory, driver, executor, loops=LOOPS)
    assert sleep_mock.call_count == LOOPS
    for call in sleep_mock.call_args_list:
        args, kwargs = call
        assert 77 <= args[0] <= 100
    assert inventory.sync.call_count == LOOPS
    assert len(nodes) == 2
    assert len(pods) == 1
Ejemplo n.º 2
0
def test_example_config_validates():
    filename = pkg_resources.resource_filename("tests.policy", "example_config.yml")
    PolicyRunner.validate_file(filename)