def test_etag_string() -> None: resp = StreamResponse() value = "0123-kotik" resp.etag = value assert resp.etag == ETag(value=value) assert resp.headers[hdrs.ETAG] == f'"{value}"'
def test_etag_any() -> None: resp = StreamResponse() resp.etag = "*" assert resp.etag == ETag(value="*") assert resp.headers[hdrs.ETAG] == "*"
resp = StreamResponse() assert resp.etag is None def test_etag_string() -> None: resp = StreamResponse() value = "0123-kotik" resp.etag = value assert resp.etag == ETag(value=value) assert resp.headers[hdrs.ETAG] == f'"{value}"' @pytest.mark.parametrize( ["etag", "expected_header"], ( (ETag(value="0123-weak-kotik", is_weak=True), 'W/"0123-weak-kotik"'), (ETag(value="0123-strong-kotik", is_weak=False), '"0123-strong-kotik"'), ), ) def test_etag_class(etag, expected_header) -> None: resp = StreamResponse() resp.etag = etag assert resp.etag == etag assert resp.headers[hdrs.ETAG] == expected_header def test_etag_any() -> None: resp = StreamResponse() resp.etag = "*" assert resp.etag == ETag(value="*")