| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
"""Property-based tests for the views module.""" |
| 17 |
|
| 18 |
from hypothesis import given |
| 19 |
from hypothesis import strategies as st |
| 20 |
from hypothesis.provisional import urls |
| 21 |
|
| 22 |
import fastkml.containers |
| 23 |
import fastkml.features |
| 24 |
import fastkml.kml |
| 25 |
import fastkml.links |
| 26 |
import fastkml.overlays |
| 27 |
from tests.base import Lxml |
| 28 |
from tests.hypothesis.common import assert_repr_roundtrip |
| 29 |
from tests.hypothesis.common import assert_str_roundtrip |
| 30 |
from tests.hypothesis.common import assert_str_roundtrip_terse |
| 31 |
from tests.hypothesis.common import assert_str_roundtrip_verbose |
| 32 |
|
| 33 |
|
| 34 |
class TestLxml(Lxml): |
| 35 |
@given( |
| 36 |
feature=st.one_of( |
| 37 |
st.builds( |
| 38 |
fastkml.containers.Document, |
| 39 |
), |
| 40 |
st.builds( |
| 41 |
fastkml.containers.Folder, |
| 42 |
), |
| 43 |
st.builds( |
| 44 |
fastkml.features.Placemark, |
| 45 |
), |
| 46 |
st.builds( |
| 47 |
fastkml.overlays.GroundOverlay, |
| 48 |
), |
| 49 |
st.builds( |
| 50 |
fastkml.overlays.PhotoOverlay, |
| 51 |
), |
| 52 |
st.builds( |
| 53 |
fastkml.features.NetworkLink, |
| 54 |
link=st.builds( |
| 55 |
fastkml.links.Link, |
| 56 |
href=urls(), |
| 57 |
), |
| 58 |
), |
| 59 |
), |
| 60 |
) |
| 61 |
def test_fuzz_document( |
| 62 |
self, |
| 63 |
feature: fastkml.features._Feature, |
| 64 |
) -> None: |
| 65 |
kml = fastkml.kml.KML( |
| 66 |
features=[feature], |
| 67 |
) |
| 68 |
|
| 69 |
assert_repr_roundtrip(kml) |
| 70 |
assert_str_roundtrip(kml) |
| 71 |
assert_str_roundtrip_terse(kml) |
| 72 |
assert_str_roundtrip_verbose(kml) |