From bcf5ead7317538be6e97d3f3d043c48bbe474a8a Mon Sep 17 00:00:00 2001 From: hyades Date: Fri, 9 Aug 2013 13:27:55 +0530 Subject: [PATCH] Changed structure of files, added pytest option to makefile --- python-api/Makefile | 5 ++++- python-api/__init__.py | 0 python-api/tests/scripts/__init__.py | 0 python-api/{test => tests/scripts}/dbusConnect.py | 0 python-api/{test => tests/scripts}/dbusConnect.sh | 0 python-api/{test => tests/scripts}/dbusConnect2.py | 0 .../{test => tests/scripts}/dbusConnection3.py | 0 python-api/{test => tests/scripts}/introspect.txt | 0 python-api/tests/unittests/__init__.py | 0 .../unittests}/test_connection.py | 10 +++++++--- .../unittests}/test_controller.py | 10 +++++++--- .../{gstswitch => tests/unittests}/test_helpers.py | 14 +++++++++----- .../{gstswitch => tests/unittests}/test_server.py | 8 ++++++-- .../unittests}/test_testsource.py | 8 ++++++-- 14 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 python-api/__init__.py create mode 100644 python-api/tests/scripts/__init__.py rename python-api/{test => tests/scripts}/dbusConnect.py (100%) rename python-api/{test => tests/scripts}/dbusConnect.sh (100%) rename python-api/{test => tests/scripts}/dbusConnect2.py (100%) rename python-api/{test => tests/scripts}/dbusConnection3.py (100%) rename python-api/{test => tests/scripts}/introspect.txt (100%) create mode 100644 python-api/tests/unittests/__init__.py rename python-api/{gstswitch => tests/unittests}/test_connection.py (98%) rename python-api/{gstswitch => tests/unittests}/test_controller.py (97%) rename python-api/{gstswitch => tests/unittests}/test_helpers.py (91%) rename python-api/{gstswitch => tests/unittests}/test_server.py (97%) rename python-api/{gstswitch => tests/unittests}/test_testsource.py (96%) diff --git a/python-api/Makefile b/python-api/Makefile index 3a7deb8..248b13d 100644 --- a/python-api/Makefile +++ b/python-api/Makefile @@ -9,8 +9,11 @@ lint: coverage: mkdir -p reports mkdir -p reports/coverage - -py.test --cov-report html --cov gstswitch gstswitch -v + -py.test --cov-report html --cov gstswitch -v mv htmlcov/*.* reports/coverage rmdir htmlcov rm *.data +pytest: + -py.test tests/unittests -v + diff --git a/python-api/__init__.py b/python-api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-api/tests/scripts/__init__.py b/python-api/tests/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-api/test/dbusConnect.py b/python-api/tests/scripts/dbusConnect.py similarity index 100% rename from python-api/test/dbusConnect.py rename to python-api/tests/scripts/dbusConnect.py diff --git a/python-api/test/dbusConnect.sh b/python-api/tests/scripts/dbusConnect.sh similarity index 100% rename from python-api/test/dbusConnect.sh rename to python-api/tests/scripts/dbusConnect.sh diff --git a/python-api/test/dbusConnect2.py b/python-api/tests/scripts/dbusConnect2.py similarity index 100% rename from python-api/test/dbusConnect2.py rename to python-api/tests/scripts/dbusConnect2.py diff --git a/python-api/test/dbusConnection3.py b/python-api/tests/scripts/dbusConnection3.py similarity index 100% rename from python-api/test/dbusConnection3.py rename to python-api/tests/scripts/dbusConnection3.py diff --git a/python-api/test/introspect.txt b/python-api/tests/scripts/introspect.txt similarity index 100% rename from python-api/test/introspect.txt rename to python-api/tests/scripts/introspect.txt diff --git a/python-api/tests/unittests/__init__.py b/python-api/tests/unittests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python-api/gstswitch/test_connection.py b/python-api/tests/unittests/test_connection.py similarity index 98% rename from python-api/gstswitch/test_connection.py rename to python-api/tests/unittests/test_connection.py index a818a81..93ea40d 100644 --- a/python-api/gstswitch/test_connection.py +++ b/python-api/tests/unittests/test_connection.py @@ -1,8 +1,12 @@ -from connection import Connection -from exception import * +import sys +import os +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../../"))) + +from gstswitch.connection import Connection +from gstswitch.exception import * import pytest from gi.repository import Gio, GLib -from mock import Mock, patch +from mock import Mock class TestAddress(object): diff --git a/python-api/gstswitch/test_controller.py b/python-api/tests/unittests/test_controller.py similarity index 97% rename from python-api/gstswitch/test_controller.py rename to python-api/tests/unittests/test_controller.py index f9c5fc1..2eb390b 100644 --- a/python-api/gstswitch/test_controller.py +++ b/python-api/tests/unittests/test_controller.py @@ -1,8 +1,12 @@ -from controller import Controller -from exception import ConnectionReturnError +import sys +import os +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../../"))) + +from gstswitch.controller import Controller +from gstswitch.exception import ConnectionReturnError import pytest from mock import Mock, patch -from connection import Connection +from gstswitch.connection import Connection from gi.repository import GLib diff --git a/python-api/gstswitch/test_helpers.py b/python-api/tests/unittests/test_helpers.py similarity index 91% rename from python-api/gstswitch/test_helpers.py rename to python-api/tests/unittests/test_helpers.py index 5f41c45..52ce0f4 100644 --- a/python-api/gstswitch/test_helpers.py +++ b/python-api/tests/unittests/test_helpers.py @@ -1,7 +1,11 @@ -from helpers import TestSources, PreviewSinks -from exception import RangeError, InvalidIndexError +import sys +import os +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../../"))) + +from gstswitch.helpers import TestSources, PreviewSinks +from gstswitch.exception import RangeError, InvalidIndexError import pytest -import testsource +import gstswitch.testsource class TestTestSourcesVideoPort(object): @@ -50,7 +54,7 @@ def run(self): def test_new_test_video(self, monkeypatch): test = TestSources(video_port=3000) - monkeypatch.setattr(testsource, 'VideoSrc', self.MockVideoSrc) + monkeypatch.setattr(gstswitch.testsource, 'VideoSrc', self.MockVideoSrc) test.new_test_video() assert test.running_tests[0] is not None assert len(test.running_tests) != 0 @@ -137,7 +141,7 @@ def end(self): def test_run(self, monkeypatch): preview = PreviewSinks() - monkeypatch.setattr(testsource, 'Preview', self.MockPreview) + monkeypatch.setattr(gstswitch.testsource, 'Preview', self.MockPreview) preview.run() assert preview.preview is not None diff --git a/python-api/gstswitch/test_server.py b/python-api/tests/unittests/test_server.py similarity index 97% rename from python-api/gstswitch/test_server.py rename to python-api/tests/unittests/test_server.py index d564237..ab5970d 100644 --- a/python-api/gstswitch/test_server.py +++ b/python-api/tests/unittests/test_server.py @@ -1,6 +1,10 @@ -from server import Server +import sys +import os +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../../"))) + +from gstswitch.server import Server import pytest -from exception import * +from gstswitch.exception import * import os import subprocess from mock import Mock diff --git a/python-api/gstswitch/test_testsource.py b/python-api/tests/unittests/test_testsource.py similarity index 96% rename from python-api/gstswitch/test_testsource.py rename to python-api/tests/unittests/test_testsource.py index 9e6a6dd..d0cc167 100644 --- a/python-api/gstswitch/test_testsource.py +++ b/python-api/tests/unittests/test_testsource.py @@ -1,5 +1,9 @@ -from exception import RangeError -from testsource import Preview, VideoSrc, BasePipeline, VideoPipeline +import sys +import os +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "../../../"))) + +from gstswitch.exception import RangeError +from gstswitch.testsource import Preview, VideoSrc, BasePipeline, VideoPipeline import pytest from mock import Mock, patch from gi.repository import Gst