Exemple #1
0
def test_helper_types():
    binding_helper.unregister_all()
    UncachedHelper.register()
    CachedHelper.register()

    uncached_helper = binding_helper._BINDING_HELPERS[0]
    cached_helper = binding_helper._BINDING_HELPERS[1]

    def smoke_test():
        cfg = write_and_load_config(role='john_doe')
        binding_helper.apply_all(cfg)
        assert cfg.task(
            0).processes()[0].cmdline().get() == 'U(hello) C(hello)'
        assert cfg.task(
            0).processes()[1].cmdline().get() == 'U(hello) C(hello)'

    # initially everything uncached (also -- multiple symbols result in a single bind)
    smoke_test()
    assert uncached_helper.binds == 1
    assert cached_helper.binds == 1
    assert cached_helper.uncached_binds == 1

    # cached helper is warm, should no longer have uncached binds
    smoke_test()
    assert uncached_helper.binds == 2
    assert cached_helper.binds == 2
    assert cached_helper.uncached_binds == 1

    # flush cache and validate miss
    binding_helper.clear_binding_caches()
    smoke_test()
    assert uncached_helper.binds == 3
    assert cached_helper.binds == 3
    assert cached_helper.uncached_binds == 2
def test_helper_types():
  binding_helper.unregister_all()
  UncachedHelper.register()
  CachedHelper.register()

  uncached_helper = binding_helper._BINDING_HELPERS[0]
  cached_helper = binding_helper._BINDING_HELPERS[1]

  def smoke_test():
    cfg = write_and_load_config(role='john_doe')
    binding_helper.apply_all(cfg)
    assert cfg.task(0).processes()[0].cmdline().get() == 'U(hello) C(hello)'
    assert cfg.task(0).processes()[1].cmdline().get() == 'U(hello) C(hello)'

  # initially everything uncached (also -- multiple symbols result in a single bind)
  smoke_test()
  assert uncached_helper.binds == 1
  assert cached_helper.binds == 1
  assert cached_helper.uncached_binds == 1

  # cached helper is warm, should no longer have uncached binds
  smoke_test()
  assert uncached_helper.binds == 2
  assert cached_helper.binds == 2
  assert cached_helper.uncached_binds == 1

  # flush cache and validate miss
  binding_helper.clear_binding_caches()
  smoke_test()
  assert uncached_helper.binds == 3
  assert cached_helper.binds == 3
  assert cached_helper.uncached_binds == 2
Exemple #3
0
def test_registry():
    binding_helper.unregister_all()
    assert len(binding_helper._BINDING_HELPERS) == 0

    UncachedHelper.register()
    assert len(binding_helper._BINDING_HELPERS) == 1

    CachedHelper.register()
    assert len(binding_helper._BINDING_HELPERS) == 2

    binding_helper.unregister_all()
    assert len(binding_helper._BINDING_HELPERS) == 0
def test_registry():
  binding_helper.unregister_all()
  assert len(binding_helper._BINDING_HELPERS) == 0

  UncachedHelper.register()
  assert len(binding_helper._BINDING_HELPERS) == 1

  CachedHelper.register()
  assert len(binding_helper._BINDING_HELPERS) == 2

  binding_helper.unregister_all()
  assert len(binding_helper._BINDING_HELPERS) == 0