Add a smoke test and remove automatic test
authorNoe Gaumont <ngaumont@logilab.fr>
Fri, 21 Jun 2019 16:31:48 +0200
changeset 71 02802ad7a598
parent 70 b13ddf344c72
child 72 f6d8e66f4b94
Add a smoke test and remove automatic test Automatic test were failing because of file entity were selected and this entity does not support kwargs. Replace these tests by a smoke test with a basic schema.
test/data/adapters.py
test/data/schema.py
test/test_treeview.py
tox.ini
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/adapters.py	Fri Jun 21 16:31:48 2019 +0200
@@ -0,0 +1,6 @@
+from cubicweb_treeview.adapters import TVITreeAdapter
+from cubicweb.predicates import is_instance
+
+
+class NoteTreeViewAdapter(TVITreeAdapter):
+    __select__ = is_instance('Note')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/schema.py	Fri Jun 21 16:31:48 2019 +0200
@@ -0,0 +1,6 @@
+from yams.buildobjs import (EntityType, SubjectRelation, String)
+
+
+class Note(EntityType):
+    content = String()
+    has_note = SubjectRelation('Note')
--- a/test/test_treeview.py	Fri Jun 21 16:28:33 2019 +0200
+++ b/test/test_treeview.py	Fri Jun 21 16:31:48 2019 +0200
@@ -14,14 +14,23 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 
-"""cubicweb-treeview automatic tests"""
-from cubicweb.devtools.testlib import AutomaticWebTest
+"""cubicweb-treeview smoke tests"""
+from cubicweb.devtools.testlib import CubicWebTC
+from mock import patch
 
 
-class AutomaticWebTest(AutomaticWebTest):
-    '''provides `to_test_etypes` and/or `list_startup_views` implementation
-    to limit test scope
-    '''
+class Treeview(CubicWebTC):
+    def test_works(self):
+        with self.admin_access.web_request() as req:
+            note = req.create_entity('Note', content=u'Title')
+            note.view("treeview")
+
+    @patch("cubicweb_treeview.views.treeview.TVDefaultTreeViewItemView.cell_call")
+    def test_overrides_DefaultTreeViewItemView(self, cell_call):
+        with self.admin_access.web_request() as req:
+            note = req.create_entity('Note', content=u'Title')
+            note.view("treeview")
+            self.assertTrue(cell_call.called)
 
 
 if __name__ == '__main__':
--- a/tox.ini	Fri Jun 21 16:28:33 2019 +0200
+++ b/tox.ini	Fri Jun 21 16:31:48 2019 +0200
@@ -4,6 +4,7 @@
 [testenv]
 deps =
   pytest
+  mock
 commands =
   {envpython} -m pytest {posargs:test}