web/test/unittest_views_forms.py
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 18 Jun 2015 18:22:55 +0200
changeset 10397 1ce4594f9cf4
parent 10142 f4a4556f23da
child 10519 0019b7888dd7
permissions -rw-r--r--
[web/json] Controller.publish must return encoded data We were mixing binary from super() and text from our params, thus wrongly returning text. Closes #5507573.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9873
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
# copyright 2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
#
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
#
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
# any later version.
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
#
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
# details.
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
#
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
from cubicweb.devtools.testlib import CubicWebTC
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
class InlinedFormTC(CubicWebTC):
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
    def test_linked_to(self):
10088
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    24
        with self.admin_access.web_request() as req:
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    25
            formview = req.vreg['views'].select(
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    26
                'inline-creation', req,
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    27
                etype='File', rtype='described_by_test', role='subject',
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    28
                peid=123,
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    29
                petype='Salesterm')
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    30
            self.assertEqual({('described_by_test', 'object'): [123]},
ac63f7ec5af0 [test/view forms] use the official, undeprecated API
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9873
diff changeset
    31
                             formview.form.linked_to)
9873
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
10142
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    33
    def test_linked_to_parent_being_created(self):
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    34
        with self.admin_access.web_request() as req:
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    35
            formview = req.vreg['views'].select(
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    36
                'inline-creation', req,
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    37
                etype='File', rtype='described_by_test', role='subject',
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    38
                peid='A',
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    39
                petype='Salesterm')
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    40
            self.assertEqual(formview.form.linked_to, {})
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    41
f4a4556f23da [views/forms] Fix EntityFieldsForm.link_to when parent entity is being created
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10088
diff changeset
    42
9873
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
if __name__ == '__main__':
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
    from logilab.common.testlib import unittest_main
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
    unittest_main()
1257e909d25e [forms] consider inline creation form information as linkto info. Closes #3161121
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46