aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Titouan Christophe <titouan.christophe@railnova.eu>2019-12-29 21:29:12 +0100
committerGravatar Yann E. MORIN <yann.morin.1998@free.fr>2019-12-29 21:38:33 +0100
commit9fa2add810c0bda2c727ce55e68b4776a944d141 (patch)
tree8a870c690b97e79283b0bde24e70d18958187f67
parent9a6448a859d9b6b55ee250dfcd84903443633f33 (diff)
downloadbuildroot-9fa2add810c0bda2c727ce55e68b4776a944d141.tar.gz
buildroot-9fa2add810c0bda2c727ce55e68b4776a944d141.tar.bz2
support/testing: add test for python-avro
This adds a test case for python-avro, with a script that performs a simple deserialization. Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
-rw-r--r--support/testing/tests/package/sample_python_avro.py23
-rw-r--r--support/testing/tests/package/test_python_avro.py11
2 files changed, 34 insertions, 0 deletions
diff --git a/support/testing/tests/package/sample_python_avro.py b/support/testing/tests/package/sample_python_avro.py
new file mode 100644
index 0000000000..79d2dcdb22
--- /dev/null
+++ b/support/testing/tests/package/sample_python_avro.py
@@ -0,0 +1,23 @@
+from io import BytesIO
+from avro.schema import Parse
+from avro.io import DatumReader, BinaryDecoder
+
+schema = Parse("""{
+"namespace": "org.buildroot.package.python_avro",
+"type": "record",
+"name": "Developer",
+"fields": [
+ {"name": "email", "type": "string"},
+ {"name": "maintainer_of", "type": "string"}
+]
+}""")
+
+example = b'<titouan.christophe@railnova.eu\x16python_avro'
+
+reader = DatumReader(schema)
+deserialized = reader.read(BinaryDecoder(BytesIO(example)))
+
+assert deserialized == {
+ 'email': 'titouan.christophe@railnova.eu',
+ 'maintainer_of': 'python_avro',
+}
diff --git a/support/testing/tests/package/test_python_avro.py b/support/testing/tests/package/test_python_avro.py
new file mode 100644
index 0000000000..6eee2760da
--- /dev/null
+++ b/support/testing/tests/package/test_python_avro.py
@@ -0,0 +1,11 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonAvro(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_AVRO=y
+ """
+ sample_scripts = ["tests/package/sample_python_avro.py"]