Ejemplo n.º 1
0
def test_products_excerpt_without_more():
    result = _excerpt(
        [
            "vendor1",
            "vendor2",
            f"vendor1{PRODUCT_SEPARATOR}product1",
            f"vendor2{PRODUCT_SEPARATOR}product2",
        ],
        "products",
    )

    assert '<span class="badge badge-primary">2</span>' in result
    assert "Product1" in result
    assert "cve?vendor=vendor1&product=product1" in result
    assert "Product2" in result
    assert "cve?vendor=vendor2&product=product2" in result
Ejemplo n.º 2
0
def test_products_excerpt_with_more():
    result = _excerpt(
        [
            "vendor1",
            "vendor2",
            "vendor3",
            "vendor4",
            f"vendor1{PRODUCT_SEPARATOR}product1",
            f"vendor2{PRODUCT_SEPARATOR}product2",
            f"vendor3{PRODUCT_SEPARATOR}product3",
            f"vendor4{PRODUCT_SEPARATOR}product4",
        ],
        "products",
    )

    assert '<span class="badge badge-primary">4</span>' in result
    assert "Product1" in result
    assert "cve?vendor=vendor1&product=product1" in result
    assert "Product2" in result
    assert "cve?vendor=vendor2&product=product2" in result
    assert "Product3" in result
    assert "cve?vendor=vendor3&product=product3" in result
    assert "<i>and 1 more</i>" in result
Ejemplo n.º 3
0
def products_excerpt(s):
    return _excerpt(s, "products")
Ejemplo n.º 4
0
def vendors_excerpt(s):
    return _excerpt(s, "vendors")
Ejemplo n.º 5
0
def tags_excerpt(s):
    return _excerpt(s, "tags")