Browse Source

added unit test framework

gwillz 3 years ago
parent
commit
e692c98fc0
8 changed files with 117 additions and 22 deletions
  1. 1 0
      .gitignore
  2. 45 17
      .gitlab-ci.yml
  3. 3 5
      avent/avent_impl.py
  4. 4 0
      tests/__init__.py
  5. 10 0
      tests/abject.py
  6. 24 0
      tests/avent_impl.py
  7. 18 0
      tests/event.py
  8. 12 0
      tests/stopthread.py

+ 1 - 0
.gitignore

@@ -7,3 +7,4 @@ build/
 html/
 doc-style.css
 mk2pylint.cfg
+.coverage

+ 45 - 17
.gitlab-ci.yml

@@ -1,32 +1,60 @@
 
-before_script:
- - wget https://git.gwillz.com.au/snippets/8/raw -O mk2pylint.cfg -q
- - wget https://git.gwillz.com.au/snippets/9/raw -O doc-style.css -q
- - pip install pylint epydoc docutils --user -q
- 
-build:
- type: build
+build:py2:
+ stage: build
+ tags:
+ - python2
+ - linux
+ script:
+ - python2 setup.py build
+ - python2 setup.py install --user
+
+build:py3:
+ stage: build
  tags:
- - python
+ - python3
+ - linux
  script:
- - python setup.py build
- - python setup.py install --user
+ - python3 setup.py build
+ - python3 setup.py install --user
 
 deploy-api:
- type: build
+ stage: deploy
  tags:
- - python
+ - python2
+ - linux
  - mk2-docs
  allow_failure: true
  script:
+ - wget https://git.gwillz.com.au/snippets/9/raw -O doc-style.css -q
  - >-
    epydoc --no-sourcecode --no-frames --output html --simple-term -vv
-   --inheritance grouped --css doc-style.css --name 'Async Events' avent
+   --inheritance grouped --css doc-style.css
+   --name 'Async Events' avent
  - cp html/* -r /srv/api/avent
  
-lint:
- type: test
+lint:py2:
+ stage: test
+ tags:
+ - python2
+ - linux
+ script:
+ - wget https://git.gwillz.com.au/snippets/8/raw -O mk2pylint.cfg -q
+ - python2 -m pylint --rcfile=mk2pylint.cfg avent --reports=no || [[ $(($? & 3)) == 0 ]]
+
+lint:py3:
+ stage: test
+ tags:
+ - python3
+ - linux
+ script:
+ - wget https://git.gwillz.com.au/snippets/8/raw -O mk2pylint.cfg -q
+ - python3 -m pylint --rcfile=mk2pylint.cfg avent --reports=no || [[ $(($? & 3)) == 0 ]]
+
+test:
+ stage: test
  tags:
- - python
+ - python3
+ - linux
  script:
- - pylint --rcfile=mk2pylint.cfg avent --reports=no --disable=fixme || [[ $(($? & 3)) == 0 ]]
+ - python3 -Bm coverage run -m unittest tests
+ - python3 -Bm coverage report -m

+ 3 - 5
avent/avent_impl.py

@@ -1,11 +1,9 @@
-import time, types
+import time, types, collections
 from avent.event import Event
 from avent.abject import Abject
-import collections
 
- # pragma pylint: disable=redefined-outer-name
- # pragma pylint: disable=global-statement
- 
+# pragma pylint: disable=global-statement
+
 _main_avents = []
 _main_decorator = None
 

+ 4 - 0
tests/__init__.py

@@ -0,0 +1,4 @@
+from tests.event import Event_test
+from tests.avent_impl import Avent_test
+from tests.abject import Abject_test
+from tests.stopthread import StopThread_test

+ 10 - 0
tests/abject.py

@@ -0,0 +1,10 @@
+import unittest
+
+class Abject_test(unittest.TestCase):
+    def test_init(self):
+        from avent.abject import Abject
+        abject = Abject()
+    
+    def test_handleEvents(self):
+        pass
+    

+ 24 - 0
tests/avent_impl.py

@@ -0,0 +1,24 @@
+import unittest
+
+class Avent_test(unittest.TestCase):
+    def test_init(self):
+        from avent.avent_impl import Avent
+        event = Avent()
+    
+    def test_add(self):
+        pass
+    
+    def test_remove(self):
+        pass
+    
+    def test_fire(self):
+        pass
+    
+    def test_fire_sychronous(self):
+        pass
+    
+    def test_contains(self):
+        pass
+    
+    def test_mainevents(self):
+        pass

+ 18 - 0
tests/event.py

@@ -0,0 +1,18 @@
+import unittest
+
+class Event_test(unittest.TestCase):
+    def test_init(self):
+        from avent.event import Event
+        event = Event()
+    
+    def test_add(self):
+        pass
+    
+    def test_remove(self):
+        pass
+    
+    def test_fire(self):
+        pass
+    
+    def test_contains(self):
+        pass

+ 12 - 0
tests/stopthread.py

@@ -0,0 +1,12 @@
+import unittest
+
+class StopThread_test(unittest.TestCase):
+    def test_init(self):
+        from avent.stopthread import StopThread
+        thread = StopThread()
+    
+    def test_stop(self):
+        pass
+    
+    def test_stopped(self):
+        pass