Ejemplo n.º 1
0
def test_simple_enrichment_forced_namespace():
    values = {1: 2, "a": "b"}
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    valid.enrich(pub, values, force_namespace=True)
    data = valid.get_enriched(pub)
    assert data == values
Ejemplo n.º 2
0
def test_get_wrong_enrichment_forced_namespace():
    pub_values = {1: 2, "a": "b"}
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    page = pagerduty.PagerDutyPublisher("url", "token")
    valid.enrich(pub, pub_values, force_namespace=True)
    assert valid.get_enriched(page) == {}
Ejemplo n.º 3
0
def test_enrichment_fails_on_duplication_different_data():
    values = {1: 2, "a": "b"}
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    valid.enrich(pub, values)
    with pytest.raises(EnrichmentFailure):
        valid.enrich(pub, {"different": "values"})
Ejemplo n.º 4
0
def test_empty_enrichment_case():
    values = {}
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    valid.enrich(pub, values)
    data = valid.get_enriched(pub)
    assert data == values
Ejemplo n.º 5
0
def test_two_enrichments_correctness_independent_of_force_reverse(bools):
    pub_values = {1: 2, "a": "b"}
    page_values = {1: 5, "a": "3", "what": "who"}
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    page = pagerduty.PagerDutyPublisher("url", "token")
    valid.enrich(page, page_values, force_namespace=bools)
    valid.enrich(pub, pub_values, force_namespace=bools)
    pub_data = valid.get_enriched(pub)
    page_data = valid.get_enriched(page)
    for item in pub_values.items():
        assert item in pub_data.items()
    for item in page_values.items():
        assert item in page_data.items()
Ejemplo n.º 6
0
def test_should_publish_low(result):
    pub = publisher.Publisher(priority_threshold=Priority.LOW)
    should = pub._should_publish(result)
    assert should is True
Ejemplo n.º 7
0
def test_should_publish_default(result):
    pub = publisher.Publisher(priority_threshold=Priority.NORMAL)
    should = pub._should_publish(result)
    assert should == (result.priority != Priority.LOW)
Ejemplo n.º 8
0
def test_should_publish_high(result):
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    should = pub._should_publish(result)
    assert should == (result.priority == Priority.CRITICAL)
Ejemplo n.º 9
0
def test_repr(result):
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    pub.__repr__()
Ejemplo n.º 10
0
def test_get_empty_enrichment():
    valid = Validation("low", Priority.LOW)
    pub = publisher.Publisher(priority_threshold=Priority.CRITICAL)
    assert valid.get_enriched(pub) == {}