Closed cleder closed 1 month ago
Review changes with SemanticDiff.
Analyzed 15 of 17 files.
Overall, the semantic diff is 18% smaller than the GitHub diff.
Filename | Status | |
---|---|---|
:grey_question: | pyproject.toml | Unsupported file format |
:heavy_check_mark: | tests/gx_test.py | 28.57% smaller |
:heavy_check_mark: | tests/registry_test.py | Analyzed |
:grey_question: | tests/ogc_conformance/data/kml/Document-places.kml | Unsupported file format |
:heavy_check_mark: | tests/geometries/geometry_test.py | 5.21% smaller |
:heavy_check_mark: | tests/geometries/linestring_test.py | Analyzed |
:heavy_check_mark: | tests/geometries/multigeometry_test.py | 0.73% smaller |
:heavy_check_mark: | tests/geometries/point_test.py | Analyzed |
:heavy_check_mark: | tests/geometries/polygon_test.py | Analyzed |
:heavy_check_mark: | fastkml/base.py | Analyzed |
:heavy_check_mark: | fastkml/enums.py | Analyzed |
:heavy_check_mark: | fastkml/features.py | 31.1% smaller |
:heavy_check_mark: | fastkml/geometry.py | 29.4% smaller |
:heavy_check_mark: | fastkml/gx.py | 3.78% smaller |
:heavy_check_mark: | fastkml/helpers.py | 36.67% smaller |
:heavy_check_mark: | fastkml/kml.py | Analyzed |
:heavy_check_mark: | fastkml/registry.py | 43.59% smaller |
This pull request implements changes to improve output verbosity control in the fastkml library. It introduces a new Verbosity
enum, modifies the RegistryItem
class to include a default
parameter, and updates various geometry classes to handle verbosity levels when generating XML output. The changes also include refactoring of some geometry classes to remove redundant attributes and improve consistency.
classDiagram
class _Geometry {
-altitude_mode: Optional[AltitudeMode]
+altitude_mode: Optional[AltitudeMode]
+__init__(...)
+__repr__() -> str
}
class Point {
+extrude: Optional[bool]
+kml_coordinates: Optional[Coordinates]
+__init__(...)
+__repr__() -> str
}
class LineString {
+extrude: Optional[bool]
+tessellate: Optional[bool]
+kml_coordinates: Optional[Coordinates]
+__init__(...)
}
class Polygon {
+extrude: Optional[bool]
+tessellate: Optional[bool]
+outer_boundary: Optional[OuterBoundaryIs]
+inner_boundaries: List[InnerBoundaryIs]
+__init__(...)
}
class MultiGeometry {
+kml_geometries: List[Union[Point, LineString, Polygon, LinearRing, Self]]
+__init__(...)
}
_Geometry <|-- Point
_Geometry <|-- LineString
_Geometry <|-- Polygon
_BaseObject <|-- MultiGeometry
classDiagram
class RegistryItem {
+ns_ids: Tuple[str, ...]
+classes: Tuple[type, ...]
+attr_name: str
+node_name: str
+get_kwarg: GetKWArgs
+set_element: SetElement
+default: Any
}
class Verbosity {
<<enumeration>>
+terse
+normal
+verbose
}
Change | Details | Files |
---|---|---|
Introduced verbosity control for XML output |
|
fastkml/enums.py fastkml/registry.py fastkml/base.py fastkml/helpers.py fastkml/geometry.py fastkml/features.py |
Refactored geometry classes for consistency |
|
fastkml/geometry.py fastkml/gx.py |
Updated test cases to reflect new verbosity control and refactored classes |
|
tests/geometries/geometry_test.py tests/geometries/linestring_test.py tests/geometries/polygon_test.py tests/geometries/point_test.py tests/geometries/multigeometry_test.py tests/gx_test.py |
The changes in this pull request include multiple modifications across various files in the fastkml
library. Key updates involve the introduction of new parameters, such as default
, to several methods, and the renaming of an enum member in fastkml/enums.py
. Additionally, several geometry classes have been adjusted to handle attributes like extrude
and tessellate
more effectively, and new tests have been added to improve coverage and validation of functionality. The pyproject.toml
file has also been updated for better dependency management and tool configuration.
File Path | Change Summary |
---|---|
fastkml/base.py | Updated etree_element method to include a new default parameter. |
fastkml/enums.py | Renamed enum member quiet to terse in Verbosity . |
fastkml/features.py | Added attributes refresh_visibility , fly_to_view , and link to NetworkLink . Set default values for visibility and isopen in _Feature . |
fastkml/geometry.py | Removed extrude and tessellate from _Geometry , added them to Point , LineString , and Polygon . Updated MultiGeometry to inherit from _BaseObject . |
fastkml/gx.py | Removed extrude and tessellate parameters from Track and MultiTrack constructors. |
fastkml/helpers.py | Introduced get_value function for attribute retrieval; updated several existing functions to use get_value . |
fastkml/kml.py | Updated etree_element method to include a default parameter in xml_subelement_list call. |
fastkml/registry.py | Updated SetElement protocol to include a default parameter; added default attribute to RegistryItem . |
pyproject.toml | Updated tool configurations, dependency management, and project metadata. |
tests/geometries/geometry_test.py | Updated assertions and added new tests focusing on geometry attributes and verbosity handling. |
tests/geometries/linestring_test.py | Added tests for invalid extrude and tessellate values; updated assertions for to_string method. |
tests/geometries/multigeometry_test.py | Added tests for MultiGeometry class with verbose settings. |
tests/geometries/point_test.py | Added tests for to_string method of Point class focusing on extrude attribute. |
tests/geometries/polygon_test.py | Added tests for Polygon class regarding extrude , tessellate , and altitude_mode parameters. |
tests/gx_test.py | Removed extrude and tessellate parameters from Track and MultiTrack tests. |
tests/registry_test.py | Updated set_element function signature to include a default parameter. |
tests/ogc_conformance/data/kml/Document-places.kml | Modified coordinates elements in KML file to include two decimal places for z-coordinates. |
fastkml/kml.py
and fastkml/base.py
involve modifications to method signatures that include a new default
parameter, which aligns with the changes made in the main PR to the etree_element
method in fastkml/base.py
.enhancement
, documentation
, Configuration changes
In the fields of KML, we hop and play,
With new defaults to brighten the day.
Fromquiet
toterse
, our enums now sing,
As geometries dance, oh what joy they bring!
With tests all updated, our code is so spry,
Hooray for the changes! Let's leap to the sky! ๐โจ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Attention: Patch coverage is 98.63636%
with 3 lines
in your changes missing coverage. Please review.
Project coverage is 98.00%. Comparing base (
79227e7
) to head (69a4c7b
). Report is 19 commits behind head on develop.
Files with missing lines | Patch % | Lines |
---|---|---|
fastkml/helpers.py | 90.90% | 0 Missing and 3 partials :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Enhanced function Parameters in fastkml/base.py A new parameter 'default=item.default' was added to 'etree_element' function to provide a better default value handling.
Improved Verbosity Level Naming The 'quiet' verbosity level was renamed to 'terse' in 'fastkml/enums.py' for better clarity.
Registry Entry Adjustments A 'default=True' was added to one registry entry, while 'default=False' was added to two others in 'fastkml/features.py' for better default value management.
Documentation Link Update The documentation link in 'NetworkLink' class in 'fastkml/features.py' was updated to provide accurate information.
Introduction of 'default' Parameter in fastkml/geometry.py The 'coordinates_subelement' function was enhanced with a 'default' parameter to provide explicit handling of default values.
Geometry Class Alterations Unused attributes 'extrude' and 'tessellate' were moved from '_Geometry' class and added to 'Point', 'LineString', and 'Polygon' classes. This leads to cleaner and more specialized classes.
Inheritance Update 'MultiGeometry' class now inherits from '_BaseObject', and not '_Geometry'. This change adds clarity to object-oriented structure.
Added New Function in fastkml/helpers.py A new function named 'get_value' was added to retrieve attribute values with better handling options. Several existing functions were updated to use 'get_value'.
Project Configuration Update The 'pyproject.toml' file was updated to remove 'test-requirements.txt' from ignored files.
Test Updates Multiple changes were made to test files including adding new tests, implementing verbosity handling, removing unnecessary attributes, and updating existing scenarios for a thorough and increased coverage verification.
KML Test Files Precision The KML test files now use more precise coordinates for higher accuracy.
Here are some key observations to aid the review process:
โฑ๏ธ Estimated effort to review: 4 ๐ต๐ต๐ต๐ตโช |
๐งช PR contains tests |
๐ No security concerns identified |
โก Recommended focus areas for review Refactoring Significant changes to the _Geometry class, including removal of 'extrude' and 'tessellate' attributes. This may affect existing code that relies on these attributes. New Functionality Introduction of 'get_value' function for handling verbosity levels. This new function needs thorough testing to ensure it correctly handles all verbosity scenarios. Test Coverage New tests added for verbosity levels in _Geometry class. Ensure these tests cover all possible scenarios, including edge cases. |
**Action:** static-tests (3.12) |
**Failed stage:** [Typecheck](https://github.com/cleder/fastkml/actions/runs/11192604078/job/31116955358) [โ] |
**Failed test name:** tests/registry_test.py |
**Failure summary:**
The action failed due to type errors in the tests/registry_test.py file. Specifically:set_element passed to the RegistryItem function has an incompatible type.SetElement , but the provided type is a Callable with a specific signature.and 252. |
Relevant error logs:```yaml 1: ##[group]Operating System 2: Ubuntu ... 296: env: 297: pythonLocation: /opt/hostedtoolcache/Python/3.12.6/x64 298: PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.6/x64/lib/pkgconfig 299: Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.6/x64 300: Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.6/x64 301: Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.6/x64 302: LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.6/x64/lib 303: ##[endgroup] 304: tests/registry_test.py:96: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 305: tests/registry_test.py:114: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 306: tests/registry_test.py:125: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 307: tests/registry_test.py:136: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 308: tests/registry_test.py:147: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 309: tests/registry_test.py:175: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 310: tests/registry_test.py:186: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 311: tests/registry_test.py:197: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 312: tests/registry_test.py:208: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 313: tests/registry_test.py:219: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 314: tests/registry_test.py:230: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 315: tests/registry_test.py:241: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 316: tests/registry_test.py:252: error: Argument "set_element" to "RegistryItem" has incompatible type "Callable[[_XMLObject, NamedArg(Element, 'element'), NamedArg(str, 'attr_name'), NamedArg(str, 'node_name'), NamedArg(int | None, 'precision'), NamedArg(Verbosity | None, 'verbosity')], None]"; expected "SetElement" [arg-type] 317: Found 13 errors in 1 file (checked 50 source files) 318: ##[error]Process completed with exit code 1. ``` |
Preparing review...
Preparing review...
Failed to generate code suggestions for PR
Explore these optional code suggestions:
Category | Suggestion | Score |
Enhancement |
Use a more specific assertion to check for the absence of an attribute___ **Instead of usingassert not hasattr(g, "tessellate") , consider using a more specific assertion to check if the tessellate attribute is not present or set to None. This will make the test more explicit about what it's checking.** [tests/geometries/geometry_test.py [76]](https://github.com/cleder/fastkml/pull/360/files#diff-c58e16d0b9d54da03108c95fc089fb3cf98368c0a35e0807127fd57d2209fd1fR76-R76) ```diff -assert not hasattr(g, "tessellate") +assert getattr(g, "tessellate", None) is None ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 |
Add assertions to check for the absence of multiple attributes___ **Consider adding assertions to check if theextrude attribute is also not present or set to None, similar to the tessellate check. This will ensure that both attributes are properly handled in the Point class.** [tests/geometries/geometry_test.py [76]](https://github.com/cleder/fastkml/pull/360/files#diff-c58e16d0b9d54da03108c95fc089fb3cf98368c0a35e0807127fd57d2209fd1fR76-R76) ```diff -assert not hasattr(g, "tessellate") +assert getattr(g, "tessellate", None) is None +assert getattr(g, "extrude", None) is None ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 | |
Add default values to optional attributes in class definition___ **Consider adding type hints for theextrude and tessellate attributes in the LineString class. This will improve code readability and help with static type checking.** [fastkml/geometry.py [549-551]](https://github.com/cleder/fastkml/pull/360/files#diff-47314ad0817fc0fdde5a4ccab1250d104c27d592f1dd0f9952b454a4e3cdf65dR549-R551) ```diff -extrude: Optional[bool] -tessellate: Optional[bool] -kml_coordinates: Optional[Coordinates] +extrude: Optional[bool] = None +tessellate: Optional[bool] = None +kml_coordinates: Optional[Coordinates] = None ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 | |
Expand the class docstring to provide more detailed information___ **Consider adding a docstring to theMultiGeometry class to explain its purpose and usage. This will improve code documentation and make it easier for other developers to understand and use the class.** [fastkml/geometry.py [1336-1337]](https://github.com/cleder/fastkml/pull/360/files#diff-47314ad0817fc0fdde5a4ccab1250d104c27d592f1dd0f9952b454a4e3cdf65dR1336-R1337) ```diff class MultiGeometry(_BaseObject): - """A container for zero or more geometry primitives.""" + """ + A container for zero or more geometry primitives. + This class represents a collection of KML geometries, which can include + Points, LineStrings, Polygons, LinearRings, and other MultiGeometries. + It allows for the grouping and manipulation of multiple geometric objects + as a single entity within a KML document. + """ + ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 | |
Use parameterized tests to reduce code duplication and improve test maintainability___ **Consider using parameterized tests for thetest_to_string_* methods. This would reduce code duplication and make it easier to add new test cases in the future.** [tests/geometries/point_test.py [60-103]](https://github.com/cleder/fastkml/pull/360/files#diff-68b57f69d1b92ba994d69ef07c436d7e56a73eeb9e800d7d95b22758d8231153R60-R103) ```diff -def test_to_string_terse_default(self) -> None: - """Test the to_string method, exclude default for extrude in terse mode.""" +import pytest + +@pytest.mark.parametrize("verbosity, extrude, expected_extrude", [ + (Verbosity.terse, False, ""), + (Verbosity.terse, True, "extrude>1"), + (Verbosity.verbose, False, "extrude>0"), + (Verbosity.verbose, True, "extrude>1"), + (Verbosity.verbose, None, "extrude>0"), +]) +def test_to_string_extrude(self, verbosity, extrude, expected_extrude): + """Test the to_string method for different verbosity and extrude values.""" p = geo.Point(1, 2) + point = Point(geometry=p, extrude=extrude) + + result = point.to_string(verbosity=verbosity) + + assert "coordinates>" in result + if expected_extrude: + assert expected_extrude in result + else: + assert "extrude" not in result - point = Point(geometry=p, extrude=False) - - assert "coordinates>" in point.to_string(verbosity=Verbosity.terse) - assert "extrude" not in point.to_string(verbosity=Verbosity.terse) - -def test_to_string_terse_non_default(self) -> None: - """Test the to_string method, include extrude when true in terse mode.""" - p = geo.Point(1, 2) - - point = Point(geometry=p, extrude=True) - - assert "coordinates>" in point.to_string(verbosity=Verbosity.terse) - assert "extrude>1" in point.to_string(verbosity=Verbosity.terse) - -def test_to_string_verbose_default(self) -> None: - """Test the to_string method, include default for extrude in verbose mode.""" - p = geo.Point(1, 2) - - point = Point(geometry=p, extrude=False) - - assert "coordinates>" in point.to_string(verbosity=Verbosity.verbose) - assert "extrude>0" in point.to_string(verbosity=Verbosity.verbose) - -def test_to_string_verbose_non_default(self) -> None: - """Test the to_string method, include extrude when true in verbose mode.""" - p = geo.Point(1, 2) - - point = Point(geometry=p, extrude=True) - - assert "coordinates>" in point.to_string(verbosity=Verbosity.verbose) - assert "extrude>1" in point.to_string(verbosity=Verbosity.verbose) - -def test_to_string_verbose_none(self) -> None: - """Test the to_string method, include extrude when true in verbose mode.""" - p = geo.Point(1, 2) - - point = Point(geometry=p, extrude=False) - - assert "coordinates>" in point.to_string(verbosity=Verbosity.verbose) - assert "extrude>0" in point.to_string(verbosity=Verbosity.verbose) - ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 | |
Use a context manager for asserting XML element counts to improve test readability and maintainability___ **Consider using a context manager for asserting the count of specific XML elements inthe test_multi_geometries_verbose method. This would make the test more readable and easier to maintain.** [tests/geometries/polygon_test.py [265-289]](https://github.com/cleder/fastkml/pull/360/files#diff-0ef5481c38be48c9edb668e71b4f2724eb62fef20501b4f46f0f4508db55ecf1R265-R289) ```diff +from contextlib import contextmanager + +@contextmanager +def assert_xml_element_count(xml, element, expected_count): + actual_count = xml.count(element) + yield + assert actual_count == expected_count, f"Expected {expected_count} occurrences of '{element}', but found {actual_count}" + def test_multi_geometries_verbose(self) -> None: - p = geo.Point(1, 2) - ls = geo.LineString(((1, 2), (2, 0))) - lr = geo.LinearRing(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))) - poly = geo.Polygon( - [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)], - [[(0.1, 0.1), (0.1, 0.9), (0.9, 0.9), (0.9, 0.1), (0.1, 0.1)]], - ) - gc = geo.GeometryCollection([p, ls, lr, poly]) - mp = geo.MultiPolygon( - [ - ( - ((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), - [((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1))], - ), - (((0.0, 0.0), (0.0, 2.0), (1.0, 1.0), (1.0, 0.0)),), - ], - ) - ml = geo.MultiLineString([[(1, 2), (3, 4)], [(5, 6), (7, 8)]]) - mgc = geo.GeometryCollection([gc, mp, ml]) - mg = MultiGeometry(ns="", geometry=mgc) + # ... (existing setup code) xml = mg.to_string(verbosity=Verbosity.verbose) - assert xml.count("tessellate>0<") == 12 # points do not have tessellate - assert xml.count("extrude>0<") == 13 - assert xml.count("altitudeMode>clampToGround<") == 13 + with assert_xml_element_count(xml, "tessellate>0<", 12): + pass # points do not have tessellate + with assert_xml_element_count(xml, "extrude>0<", 13): + pass + with assert_xml_element_count(xml, "altitudeMode>clampToGround<", 13): + pass ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 | |
Use a parameterized test to reduce code duplication and improve test maintainability for LineString to_string methods___ **Consider using a parameterized test for thetest_to_string_* methods to reduce code duplication and improve test maintainability.** [tests/geometries/linestring_test.py [178-221]](https://github.com/cleder/fastkml/pull/360/files#diff-45bb62f1478c8e27bd84d343f667c902609abe57de39b34600795afe3acf4a22R178-R221) ```diff -def test_to_string_terse_default(self) -> None: +import pytest + +@pytest.mark.parametrize("verbosity, extrude, tessellate, expected_tessellate, expected_extrude", [ + (Verbosity.terse, False, False, "", ""), + (Verbosity.terse, True, True, "tessellate>1", "extrude>1"), + (Verbosity.verbose, False, False, "tessellate>0", "extrude>0"), + (Verbosity.verbose, True, True, "tessellate>1", "extrude>1"), + (Verbosity.verbose, None, None, "tessellate>0", "extrude>0"), +]) +def test_to_string(self, verbosity, extrude, tessellate, expected_tessellate, expected_extrude): ls = geo.LineString(((1, 2), (2, 0))) - line_string = LineString(geometry=ls, extrude=False, tessellate=False) + line_string = LineString(geometry=ls, extrude=extrude, tessellate=tessellate) - xml = line_string.to_string(verbosity=Verbosity.terse) + xml = line_string.to_string(verbosity=verbosity) - assert "tessellate" not in xml - assert "extrude" not in xml + if expected_tessellate: + assert expected_tessellate in xml + else: + assert "tessellate" not in xml -def test_to_string_terse(self) -> None: - ls = geo.LineString(((1, 2), (2, 0))) - line_string = LineString(geometry=ls, extrude=True, tessellate=True) + if expected_extrude: + assert expected_extrude in xml + else: + assert "extrude" not in xml - xml = line_string.to_string(verbosity=Verbosity.terse) - - assert "tessellate>1" in xml - assert "extrude>1" in xml - -def test_to_string_verbose_default(self) -> None: - ls = geo.LineString(((1, 2), (2, 0))) - line_string = LineString(geometry=ls, extrude=False, tessellate=False) - - xml = line_string.to_string(verbosity=Verbosity.verbose) - - assert "tessellate>0" in xml - assert "extrude>0" in xml - -def test_to_string_verbose(self) -> None: - ls = geo.LineString(((1, 2), (2, 0))) - line_string = LineString(geometry=ls, extrude=True, tessellate=True) - - xml = line_string.to_string(verbosity=Verbosity.verbose) - - assert "tessellate>1" in xml - assert "extrude>1" in xml - -def test_to_string_verbose_none(self) -> None: - ls = geo.LineString(((1, 2), (2, 0))) - line_string = LineString(geometry=ls) - - xml = line_string.to_string(verbosity=Verbosity.verbose) - - assert "tessellate>0" in xml - assert "extrude>0" in xml - ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: | 7 |
๐ก Need additional feedback ? start a PR chat
Preparing review...
Preparing review...
Summary by Sourcery
Add output verbosity control for XML serialization, refactor geometry handling for 'extrude' and 'tessellate' attributes, and update tests to cover new verbosity features and error handling.
New Features:
Enhancements:
Tests:
Summary by CodeRabbit
Release Notes
New Features
NetworkLink
and_Feature
classes.extrude
andtessellate
attributes to specific geometry classes.get_value
function for streamlined attribute retrieval.Bug Fixes
Placemark
entries.Tests
LineString
class and improved assertions across various test files.MultiGeometry
class with new verbosity checks.Documentation
pyproject.toml
for better dependency management.