From d05b55ee97b472d594924545c252010152750ae6 Mon Sep 17 00:00:00 2001 From: jesrypandawa Date: Thu, 9 Jun 2022 13:22:23 +0700 Subject: [PATCH] test: testing --- .github/workflows/python_package.yml | 7 ++++--- dagger-py-functions/data/test_file.txt | 1 + dagger-py-functions/requirements.txt | 1 + .../tests}/__init__.py | 0 .../scalar => dagger-py-functions/tests/udfs}/__init__.py | 0 .../tests/udfs/scalar/__init__.py | 0 dagger-py-functions/tests/udfs/scalar/sample_test.py | 7 +++++++ .../udfs/scalar/sample.py | 4 +++- python-functions/requirements.txt | 2 -- 9 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 dagger-py-functions/data/test_file.txt create mode 100644 dagger-py-functions/requirements.txt rename {python-functions => dagger-py-functions/tests}/__init__.py (100%) rename {python-functions/test/scalar => dagger-py-functions/tests/udfs}/__init__.py (100%) rename python-functions/data/test_file.txt => dagger-py-functions/tests/udfs/scalar/__init__.py (100%) create mode 100644 dagger-py-functions/tests/udfs/scalar/sample_test.py rename {python-functions => dagger-py-functions}/udfs/scalar/sample.py (57%) delete mode 100644 python-functions/requirements.txt diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml index 2159c543c..e44fbfd15 100644 --- a/.github/workflows/python_package.yml +++ b/.github/workflows/python_package.yml @@ -12,12 +12,13 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Zip Python Udf run: | - zip -r python_udfs.zip python-functions/udfs -x "*/__init__.py" - zip -r python_functions_${{ env.RELEASE_VERSION }}.zip python-functions/requirements.txt python-functions/data python_udfs.zip + zip -r python_udfs.zip dagger-py-functions/udfs -x "*/__init__.py" + zip -r data.zip dagger-py-functions/data + zip -r dagger-py-functions.zip dagger-py-functions/requirements.txt data.zip python_udfs.zip - name: Upload Release uses: ncipollo/release-action@v1 with: - artifacts: python_functions_${{ env.RELEASE_VERSION }}.zip + artifacts: dagger-py-functions.zip allowUpdates: true omitNameDuringUpdate: true omitBodyDuringUpdate: true diff --git a/dagger-py-functions/data/test_file.txt b/dagger-py-functions/data/test_file.txt new file mode 100644 index 000000000..5c346a471 --- /dev/null +++ b/dagger-py-functions/data/test_file.txt @@ -0,0 +1 @@ +added_text \ No newline at end of file diff --git a/dagger-py-functions/requirements.txt b/dagger-py-functions/requirements.txt new file mode 100644 index 000000000..6a3d7bca6 --- /dev/null +++ b/dagger-py-functions/requirements.txt @@ -0,0 +1 @@ +pytest==7.1.2 \ No newline at end of file diff --git a/python-functions/__init__.py b/dagger-py-functions/tests/__init__.py similarity index 100% rename from python-functions/__init__.py rename to dagger-py-functions/tests/__init__.py diff --git a/python-functions/test/scalar/__init__.py b/dagger-py-functions/tests/udfs/__init__.py similarity index 100% rename from python-functions/test/scalar/__init__.py rename to dagger-py-functions/tests/udfs/__init__.py diff --git a/python-functions/data/test_file.txt b/dagger-py-functions/tests/udfs/scalar/__init__.py similarity index 100% rename from python-functions/data/test_file.txt rename to dagger-py-functions/tests/udfs/scalar/__init__.py diff --git a/dagger-py-functions/tests/udfs/scalar/sample_test.py b/dagger-py-functions/tests/udfs/scalar/sample_test.py new file mode 100644 index 000000000..7205f36f3 --- /dev/null +++ b/dagger-py-functions/tests/udfs/scalar/sample_test.py @@ -0,0 +1,7 @@ +from udfs.scalar.sample import sample + + +def testSample(): + f = sample._func + assert f("input_text") == "input_text_added_text" + diff --git a/python-functions/udfs/scalar/sample.py b/dagger-py-functions/udfs/scalar/sample.py similarity index 57% rename from python-functions/udfs/scalar/sample.py rename to dagger-py-functions/udfs/scalar/sample.py index 0c517f9c0..21d19a216 100644 --- a/python-functions/udfs/scalar/sample.py +++ b/dagger-py-functions/udfs/scalar/sample.py @@ -4,4 +4,6 @@ @udf(result_type=DataTypes.STRING()) def sample(text): - return text + "_added_text" \ No newline at end of file + file = open("data/test_file.txt", "r") + data = file.read() + return text + '_' + data diff --git a/python-functions/requirements.txt b/python-functions/requirements.txt deleted file mode 100644 index 64e47665c..000000000 --- a/python-functions/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest==7.1.2 -flake8==4.0.1 \ No newline at end of file