Skip to content

Commit

Permalink
Always create description tag
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Nov 8, 2023
1 parent 0f5999b commit e0b0b79
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/lib/appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def add_release(
releases.insert(0, release)
_fill_padding(release)

description = ElementTree.Element("description")
description.text = ""

release.append(description)
_fill_padding(description)

tree.write(
dst,
# XXX: lxml uses single quotes for doctype line if generated with
Expand Down
38 changes: 28 additions & 10 deletions tests/test_appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def test_simple(self):
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
<release version="1.2.3" date="2019-01-01"/>
</releases>
</component>
Expand All @@ -70,7 +72,9 @@ def test_mixed_indentation(self):
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
<release version="1.2.3" date="2019-01-01"/>
<release version="1.2.3" date="2019-01-01"/>
</releases>
Expand Down Expand Up @@ -119,7 +123,9 @@ def test_comment(self):
<component type="desktop">
<!-- I am the walrus -->
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
<release version="1.2.3" date="2019-01-01"/>
</releases>
</component>
Expand All @@ -137,14 +143,16 @@ def test_no_releases(self):
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</component>
""".strip(),
)

def test_empty_releases(self):
"""No whitespace is generated between <release /> and </releases>."""
"""No whitespace is generated between </release> and </releases>."""
self._do_test(
"""
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -156,7 +164,9 @@ def test_empty_releases(self):
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</component>
""".strip(),
Expand Down Expand Up @@ -186,7 +196,9 @@ def test_double_comment_within_root(self):
-->
<name>First element needed</name>
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</application>
""".strip(),
Expand Down Expand Up @@ -219,7 +231,9 @@ def test_comment_outside_root(self):
-->
<application>
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</application>
""".strip(),
Expand All @@ -238,7 +252,9 @@ def test_amp_as_amp(self):
<component type="desktop">
<name>🍦 &amp; 🎂</name>
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</component>
""".strip(),
Expand All @@ -259,7 +275,9 @@ def test_amp_as_codepoint(self):
<component type="desktop">
<name>🦝 &#38; 🍒</name>
<releases>
<release version="4.5.6" date="2020-02-02"/>
<release version="4.5.6" date="2020-02-02">
<description></description>
</release>
</releases>
</component>
""".strip(),
Expand Down

0 comments on commit e0b0b79

Please sign in to comment.