diff --git a/.github/workflows/run_all_tests.yaml b/.github/workflows/run_all_tests.yaml new file mode 100644 index 0000000..e1b2a79 --- /dev/null +++ b/.github/workflows/run_all_tests.yaml @@ -0,0 +1,17 @@ +name: run_all_tests + +on: [push, pull_request, workflow_dispatch] + +jobs: + RunAllTests: + runs-on: ubuntu-latest + container: python + steps: + - uses: actions/checkout@v2 + - name: run_all_tests + run: | + pip install -r requirements.txt + pip install -r test-requirements.txt + python -m pytest + + diff --git a/getAllImagesFolder/dataSub/test2.txt b/getAllImagesFolder/dataSub/test2.txt new file mode 100644 index 0000000..e69de29 diff --git a/getAllImagesFolder/test1.txt b/getAllImagesFolder/test1.txt new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..496c3ae Binary files /dev/null and b/requirements.txt differ diff --git a/src/getAllImagesFunction.py b/src/getAllImagesFunction.py new file mode 100644 index 0000000..0098e53 --- /dev/null +++ b/src/getAllImagesFunction.py @@ -0,0 +1,12 @@ +import os + + + +def getAllImages(imageFolder): + images = [] + + for path, subdirs, files in os.walk(imageFolder): + for name in files: + images.append(os.path.join(path,name)) + + return images \ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +pytest diff --git a/test/test_Get_All_Images.py b/test/test_Get_All_Images.py new file mode 100644 index 0000000..95428be --- /dev/null +++ b/test/test_Get_All_Images.py @@ -0,0 +1,30 @@ +import os +import test +import pathlib +import sys +sys.path.insert(0, './src') + +from getAllImagesFunction import getAllImages + + +def test_images(): + + imageFolder = r"/getAllImagesFolder" #folder with all the images + + imageFolderPath = os.getcwd()+ imageFolder + imageFolderPath.encode('unicode_escape') + + print (imageFolderPath) + + images = getAllImages(imageFolderPath) + + imagesRel = [] + + for image in images: + image = os.path.relpath(image, imageFolderPath) + imagesRel.append(image) + + + print(len(imagesRel)) + assert len(imagesRel) == 2 + diff --git a/testGetAllImages.py b/testGetAllImages.py new file mode 100644 index 0000000..fd2045b --- /dev/null +++ b/testGetAllImages.py @@ -0,0 +1,23 @@ +from src.getAllImagesFunction import * +import os + + +imageFolder = "\getAllImagesFolder" #folder with all the images + +imageFolderPath = os.getcwd()+ imageFolder +imageFolderPath.encode('unicode_escape') + +print (imageFolderPath) + +images = getAllImages(imageFolderPath) + +imagesRel = [] + +for image in images: + image = os.path.relpath(image, imageFolderPath) + imagesRel.append(image) + + + + +print(imagesRel)