Ejemplo n.º 1
0
def test_notify_payload():
    data = create_notify_payload("239.255.255.250:1900", "testdevice", "ssdpy-test")
    data_headers = parse_headers(data)
    assert data_headers.get("host") == "239.255.255.250:1900"
    assert data_headers.get("nt") == "testdevice"
    assert data_headers.get("usn") == "ssdpy-test"
    assert data_headers.get("non-existant-header") is None
Ejemplo n.º 2
0
def test_notify_age():
    data = create_notify_payload("239.255.255.250:1900", "testdevice", "ssdpy-test", max_age=999)
    data_headers = parse_headers(data)
    assert data_headers.get("host") == "239.255.255.250:1900"
    assert data_headers.get("nt") == "testdevice"
    assert data_headers.get("usn") == "ssdpy-test"
    assert data_headers.get("non-existant-header") is None
    assert data_headers.get("cache-control") == "max-age=999"
Ejemplo n.º 3
0
def test_notify_extra_fields():
    data = create_notify_payload(
        "239.255.255.250:1900",
        "testdevice",
        "ssdpy-test",
        extra_fields={"test-header": "test-value", "test-header.domain.com": "test-value2"},
    )
    data_headers = parse_headers(data)
    assert data_headers.get("test-header") == "test-value"
    assert data_headers.get("test-header.domain.com") == "test-value2"
    assert data_headers.get("non-existant-header") is None
Ejemplo n.º 4
0
def test_notify_edge_cases():
    with pytest.raises(ValueError):
        create_notify_payload("x", "y", "z", max_age="not-a-number")