[elbe-devel] [PATCH 4/6] tests: finetuning: add tests for <file>

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Jan 27 09:59:18 CET 2025


The different encoding schemes are not always obvious.
Add some unittests.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/tests/test_finetuning.py | 75 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/elbepack/tests/test_finetuning.py b/elbepack/tests/test_finetuning.py
index 17b91f338d6514ba997e9a03c2856778aed83512..33c841751250994d93cd57407c4817bc48c7b66a 100644
--- a/elbepack/tests/test_finetuning.py
+++ b/elbepack/tests/test_finetuning.py
@@ -86,3 +86,78 @@ def test_ln(target):
     assert target.exists('foo')
     assert target.islink('bar')
     assert target.readlink('bar') == 'foo'
+
+
+def test_file_plain(target):
+    finetune(target, """
+    <file encoding="plain" dst="foo">bar</file>
+    """)
+    assert target.read_file('foo') == 'bar'
+
+    finetune(target, """
+<file encoding="plain" dst="foo">
+    bar
+</file>
+    """)
+    assert target.read_file('foo') == 'bar'
+
+    finetune(target, """
+<file encoding="plain" dst="foo">
+
+    baz
+
+</file>
+    """)
+    assert target.read_file('foo') == 'baz'
+
+
+def test_file_raw(target):
+    finetune(target, """
+    <file encoding="raw" dst="foo">
+bar
+    </file>
+    """)
+    assert target.read_file('foo') == 'bar'
+
+    finetune(target, """
+    <file encoding="raw" dst="foo">
+
+baz
+
+    </file>
+    """)
+    assert target.read_file('foo') == '\nbaz\n'
+
+    # This is probably unintentional
+    finetune(target, """
+    <file encoding="raw" dst="foo">foo
+baz
+    </file>
+    """)
+    assert target.read_file('foo') == 'baz'
+
+
+def test_file_base64(target):
+    finetune(target, """
+    <file encoding="base64" dst="foo">YmFyCg==</file>
+    """)
+    assert target.read_file('foo') == 'bar\n'
+
+    finetune(target, """
+    <file encoding="base64" dst="foo">
+         YmFyCg==
+    </file>
+    """)
+    assert target.read_file('foo') == 'bar\n'
+
+
+def test_file_append(target):
+    finetune(target, """
+    <file encoding="plain" dst="foo">bar</file>
+    """)
+    assert target.read_file('foo') == 'bar'
+
+    finetune(target, """
+    <file encoding="plain" dst="foo" append="true">baz</file>
+    """)
+    assert target.read_file('foo') == 'barbaz'

-- 
2.48.1



More information about the elbe-devel mailing list