{"action":"created","comment":{"url":"https://api.github.com/repos/qgis/QGIS/pulls/comments/144813364","pull_request_review_id":69520716,"id":144813364,"diff_hunk":"@@ -0,0 +1,95 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"QGIS Unit tests for edit widgets.\n+\n+.. note:: This program is free software; you can redistribute it and/or modify\n+it under the terms of the GNU General Public License as published by\n+the Free Software Foundation; either version 2 of the License, or\n+(at your option) any later version.\n+\"\"\"\n+__author__ = 'Matthias Kuhn'\n+__date__ = '28/11/2015'\n+__copyright__ = 'Copyright 2015, The QGIS Project'\n+# This will get replaced with a git SHA1 when you do a git archive\n+__revision__ = '$Format:%H$'\n+\n+import qgis  # NOQA\n+\n+import os\n+\n+from qgis.core import (\n+    QgsFeature,\n+    QgsVectorLayer,\n+    QgsProject,\n+    QgsRelation,\n+    QgsTransaction,\n+    QgsFeatureRequest,\n+    QgsVectorLayerTools\n+)\n+\n+from qgis.gui import (\n+    QgsGui,\n+    QgsRelationWidgetWrapper,\n+    QgsAttributeEditorContext\n+)\n+\n+from qgis.PyQt.QtCore import QTimer\n+from qgis.PyQt.QtWidgets import QToolButton, QTableView, QApplication\n+from qgis.testing import start_app, unittest\n+\n+start_app()\n+\n+\n+class TestQgsDefaultValueTransaction(unittest.TestCase):\n+\n+    @classmethod\n+    def setUpClass(cls):\n+        \"\"\"\n+        Setup the involved layer\n+        :return:\n+        \"\"\"\n+        cls.dbconn = 'service=\\'qgis_test\\''\n+        if 'QGIS_PGTEST_DB' in os.environ:\n+            cls.dbconn = os.environ['QGIS_PGTEST_DB']\n+        # Create test layer\n+        cls.vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\\'pk\\' table=\"qgis_test\".\"someData\" sql=', 'points', 'postgres')\n+\n+        QgsProject.instance().addMapLayer(cls.vl)\n+        QgsProject.instance().setAutoTransaction(True)\n+\n+        assert(cls.vl.isValid())\n+\n+\n+    def setUp(self):\n+        self.startTransaction()\n+\n+    def tearDown(self):\n+        self.rollbackTransaction()\n+\n+    def test_transaction_add_feature_with_default_value(self):\n+        \"\"\"\n+        Check if a feature can be added programmaticaly with a default value in transaction mode\n+        \"\"\"\n+\n+        with edit(self.vl):\n+            f = QgsFeature()\n+            init_fields = self.vl.dataProvider().fields()","path":"tests/src/python/test_qgsdefaultvaluetransaction.py","position":75,"original_position":75,"commit_id":"04a6b58e7bb560d316ea7f39e22d9bc398e92019","original_commit_id":"04a6b58e7bb560d316ea7f39e22d9bc398e92019","user":{"login":"m-kuhn","id":588407,"avatar_url":"https://avatars1.githubusercontent.com/u/588407?v=4","gravatar_id":"","url":"https://api.github.com/users/m-kuhn","html_url":"https://github.com/m-kuhn","followers_url":"https://api.github.com/users/m-kuhn/followers","following_url":"https://api.github.com/users/m-kuhn/following{/other_user}","gists_url":"https://api.github.com/users/m-kuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/m-kuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-kuhn/subscriptions","organizations_url":"https://api.github.com/users/m-kuhn/orgs","repos_url":"https://api.github.com/users/m-kuhn/repos","events_url":"https://api.github.com/users/m-kuhn/events{/privacy}","received_events_url":"https://api.github.com/users/m-kuhn/received_events","type":"User","site_admin":false},"body":"Oh, and I think you can directly put that in the `f = QgsFeature( fields )` constructor","created_at":"2017-10-16T10:47:14Z","updated_at":"2017-10-16T10:47:14Z","html_url":"https://github.com/qgis/QGIS/pull/5378#discussion_r144813364","pull_request_url":"https://api.github.com/repos/qgis/QGIS/pulls/5378","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/comments/144813364"},"html":{"href":"https://github.com/qgis/QGIS/pull/5378#discussion_r144813364"},"pull_request":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/5378"}},"in_reply_to_id":144813266},"pull_request":{"url":"https://api.github.com/repos/qgis/QGIS/pulls/5378","id":146738809,"html_url":"https://github.com/qgis/QGIS/pull/5378","diff_url":"https://github.com/qgis/QGIS/pull/5378.diff","patch_url":"https://github.com/qgis/QGIS/pull/5378.patch","issue_url":"https://api.github.com/repos/qgis/QGIS/issues/5378","number":5378,"state":"open","locked":false,"title":"add test for adding feature in transaction mode with default value","user":{"login":"3nids","id":127259,"avatar_url":"https://avatars1.githubusercontent.com/u/127259?v=4","gravatar_id":"","url":"https://api.github.com/users/3nids","html_url":"https://github.com/3nids","followers_url":"https://api.github.com/users/3nids/followers","following_url":"https://api.github.com/users/3nids/following{/other_user}","gists_url":"https://api.github.com/users/3nids/gists{/gist_id}","starred_url":"https://api.github.com/users/3nids/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3nids/subscriptions","organizations_url":"https://api.github.com/users/3nids/orgs","repos_url":"https://api.github.com/users/3nids/repos","events_url":"https://api.github.com/users/3nids/events{/privacy}","received_events_url":"https://api.github.com/users/3nids/received_events","type":"User","site_admin":false},"body":"add a test to detect failure on adding feature with default value in transaction mode.\r\nshould fail.","created_at":"2017-10-16T09:41:37Z","updated_at":"2017-10-16T10:47:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71673e286896504d75517d847424524af1f37004","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/qgis/QGIS/pulls/5378/commits","review_comments_url":"https://api.github.com/repos/qgis/QGIS/pulls/5378/comments","review_comment_url":"https://api.github.com/repos/qgis/QGIS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/qgis/QGIS/issues/5378/comments","statuses_url":"https://api.github.com/repos/qgis/QGIS/statuses/04a6b58e7bb560d316ea7f39e22d9bc398e92019","head":{"label":"3nids:test_transaction_defval_218","ref":"test_transaction_defval_218","sha":"04a6b58e7bb560d316ea7f39e22d9bc398e92019","user":{"login":"3nids","id":127259,"avatar_url":"https://avatars1.githubusercontent.com/u/127259?v=4","gravatar_id":"","url":"https://api.github.com/users/3nids","html_url":"https://github.com/3nids","followers_url":"https://api.github.com/users/3nids/followers","following_url":"https://api.github.com/users/3nids/following{/other_user}","gists_url":"https://api.github.com/users/3nids/gists{/gist_id}","starred_url":"https://api.github.com/users/3nids/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3nids/subscriptions","organizations_url":"https://api.github.com/users/3nids/orgs","repos_url":"https://api.github.com/users/3nids/repos","events_url":"https://api.github.com/users/3nids/events{/privacy}","received_events_url":"https://api.github.com/users/3nids/received_events","type":"User","site_admin":false},"repo":{"id":7640359,"name":"QGIS","full_name":"3nids/QGIS","owner":{"login":"3nids","id":127259,"avatar_url":"https://avatars1.githubusercontent.com/u/127259?v=4","gravatar_id":"","url":"https://api.github.com/users/3nids","html_url":"https://github.com/3nids","followers_url":"https://api.github.com/users/3nids/followers","following_url":"https://api.github.com/users/3nids/following{/other_user}","gists_url":"https://api.github.com/users/3nids/gists{/gist_id}","starred_url":"https://api.github.com/users/3nids/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3nids/subscriptions","organizations_url":"https://api.github.com/users/3nids/orgs","repos_url":"https://api.github.com/users/3nids/repos","events_url":"https://api.github.com/users/3nids/events{/privacy}","received_events_url":"https://api.github.com/users/3nids/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/3nids/QGIS","description":"QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)","fork":true,"url":"https://api.github.com/repos/3nids/QGIS","forks_url":"https://api.github.com/repos/3nids/QGIS/forks","keys_url":"https://api.github.com/repos/3nids/QGIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3nids/QGIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3nids/QGIS/teams","hooks_url":"https://api.github.com/repos/3nids/QGIS/hooks","issue_events_url":"https://api.github.com/repos/3nids/QGIS/issues/events{/number}","events_url":"https://api.github.com/repos/3nids/QGIS/events","assignees_url":"https://api.github.com/repos/3nids/QGIS/assignees{/user}","branches_url":"https://api.github.com/repos/3nids/QGIS/branches{/branch}","tags_url":"https://api.github.com/repos/3nids/QGIS/tags","blobs_url":"https://api.github.com/repos/3nids/QGIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3nids/QGIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3nids/QGIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/3nids/QGIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3nids/QGIS/statuses/{sha}","languages_url":"https://api.github.com/repos/3nids/QGIS/languages","stargazers_url":"https://api.github.com/repos/3nids/QGIS/stargazers","contributors_url":"https://api.github.com/repos/3nids/QGIS/contributors","subscribers_url":"https://api.github.com/repos/3nids/QGIS/subscribers","subscription_url":"https://api.github.com/repos/3nids/QGIS/subscription","commits_url":"https://api.github.com/repos/3nids/QGIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/3nids/QGIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/3nids/QGIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/3nids/QGIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/3nids/QGIS/contents/{+path}","compare_url":"https://api.github.com/repos/3nids/QGIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3nids/QGIS/merges","archive_url":"https://api.github.com/repos/3nids/QGIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3nids/QGIS/downloads","issues_url":"https://api.github.com/repos/3nids/QGIS/issues{/number}","pulls_url":"https://api.github.com/repos/3nids/QGIS/pulls{/number}","milestones_url":"https://api.github.com/repos/3nids/QGIS/milestones{/number}","notifications_url":"https://api.github.com/repos/3nids/QGIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3nids/QGIS/labels{/name}","releases_url":"https://api.github.com/repos/3nids/QGIS/releases{/id}","deployments_url":"https://api.github.com/repos/3nids/QGIS/deployments","created_at":"2013-01-16T06:16:23Z","updated_at":"2016-09-20T08:12:39Z","pushed_at":"2017-10-16T09:38:34Z","git_url":"git://github.com/3nids/QGIS.git","ssh_url":"git@github.com:3nids/QGIS.git","clone_url":"https://github.com/3nids/QGIS.git","svn_url":"https://github.com/3nids/QGIS","homepage":"http://qgis.org","size":1194536,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"qgis:release-2_18","ref":"release-2_18","sha":"3dfe1b35ef5a082591aa9d99e15b25d0164ca312","user":{"login":"qgis","id":483444,"avatar_url":"https://avatars3.githubusercontent.com/u/483444?v=4","gravatar_id":"","url":"https://api.github.com/users/qgis","html_url":"https://github.com/qgis","followers_url":"https://api.github.com/users/qgis/followers","following_url":"https://api.github.com/users/qgis/following{/other_user}","gists_url":"https://api.github.com/users/qgis/gists{/gist_id}","starred_url":"https://api.github.com/users/qgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qgis/subscriptions","organizations_url":"https://api.github.com/users/qgis/orgs","repos_url":"https://api.github.com/users/qgis/repos","events_url":"https://api.github.com/users/qgis/events{/privacy}","received_events_url":"https://api.github.com/users/qgis/received_events","type":"Organization","site_admin":false},"repo":{"id":1690480,"name":"QGIS","full_name":"qgis/QGIS","owner":{"login":"qgis","id":483444,"avatar_url":"https://avatars3.githubusercontent.com/u/483444?v=4","gravatar_id":"","url":"https://api.github.com/users/qgis","html_url":"https://github.com/qgis","followers_url":"https://api.github.com/users/qgis/followers","following_url":"https://api.github.com/users/qgis/following{/other_user}","gists_url":"https://api.github.com/users/qgis/gists{/gist_id}","starred_url":"https://api.github.com/users/qgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qgis/subscriptions","organizations_url":"https://api.github.com/users/qgis/orgs","repos_url":"https://api.github.com/users/qgis/repos","events_url":"https://api.github.com/users/qgis/events{/privacy}","received_events_url":"https://api.github.com/users/qgis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qgis/QGIS","description":"QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)","fork":false,"url":"https://api.github.com/repos/qgis/QGIS","forks_url":"https://api.github.com/repos/qgis/QGIS/forks","keys_url":"https://api.github.com/repos/qgis/QGIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qgis/QGIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qgis/QGIS/teams","hooks_url":"https://api.github.com/repos/qgis/QGIS/hooks","issue_events_url":"https://api.github.com/repos/qgis/QGIS/issues/events{/number}","events_url":"https://api.github.com/repos/qgis/QGIS/events","assignees_url":"https://api.github.com/repos/qgis/QGIS/assignees{/user}","branches_url":"https://api.github.com/repos/qgis/QGIS/branches{/branch}","tags_url":"https://api.github.com/repos/qgis/QGIS/tags","blobs_url":"https://api.github.com/repos/qgis/QGIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qgis/QGIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qgis/QGIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/qgis/QGIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qgis/QGIS/statuses/{sha}","languages_url":"https://api.github.com/repos/qgis/QGIS/languages","stargazers_url":"https://api.github.com/repos/qgis/QGIS/stargazers","contributors_url":"https://api.github.com/repos/qgis/QGIS/contributors","subscribers_url":"https://api.github.com/repos/qgis/QGIS/subscribers","subscription_url":"https://api.github.com/repos/qgis/QGIS/subscription","commits_url":"https://api.github.com/repos/qgis/QGIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/qgis/QGIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/qgis/QGIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/qgis/QGIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/qgis/QGIS/contents/{+path}","compare_url":"https://api.github.com/repos/qgis/QGIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qgis/QGIS/merges","archive_url":"https://api.github.com/repos/qgis/QGIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qgis/QGIS/downloads","issues_url":"https://api.github.com/repos/qgis/QGIS/issues{/number}","pulls_url":"https://api.github.com/repos/qgis/QGIS/pulls{/number}","milestones_url":"https://api.github.com/repos/qgis/QGIS/milestones{/number}","notifications_url":"https://api.github.com/repos/qgis/QGIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qgis/QGIS/labels{/name}","releases_url":"https://api.github.com/repos/qgis/QGIS/releases{/id}","deployments_url":"https://api.github.com/repos/qgis/QGIS/deployments","created_at":"2011-05-02T08:06:26Z","updated_at":"2017-10-16T03:19:10Z","pushed_at":"2017-10-16T10:02:14Z","git_url":"git://github.com/qgis/QGIS.git","ssh_url":"git@github.com:qgis/QGIS.git","clone_url":"https://github.com/qgis/QGIS.git","svn_url":"https://github.com/qgis/QGIS","homepage":"http://qgis.org","size":1327513,"stargazers_count":1589,"watchers_count":1589,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1124,"mirror_url":null,"open_issues_count":102,"forks":1124,"open_issues":102,"watchers":1589,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/5378"},"html":{"href":"https://github.com/qgis/QGIS/pull/5378"},"issue":{"href":"https://api.github.com/repos/qgis/QGIS/issues/5378"},"comments":{"href":"https://api.github.com/repos/qgis/QGIS/issues/5378/comments"},"review_comments":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/5378/comments"},"review_comment":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/5378/commits"},"statuses":{"href":"https://api.github.com/repos/qgis/QGIS/statuses/04a6b58e7bb560d316ea7f39e22d9bc398e92019"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"m-kuhn"}}