Don't modify project-templates to add job name attributes

A recent change began performing full validation on project-pipeline
job variants rather than deferring to the jobparser.  However,
we were modifying the config object inside the project-template parser
to add the job name, before passing it to the job parser.  This meant
that the template passed validation the first time, but during a
subsequent reconfiguration, the cached value would already have the
name attribute and fail validation.

This change stops adding the name attribute, instead passing it to
the jobparser.  It also disables validation by the jobparser in the
case that the project-template parser has already performed it, so that
we don't slow reconfiguration.

Change-Id: I080b4dd01ac40363a932c0853f0f9670b1e2c511
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 4b0bfc5..28e2b08 100755
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -905,6 +905,50 @@
         self.assertIn('expected str for dictionary value',
                       A.messages[0], "A should have a syntax error reported")
 
+    def test_project_template(self):
+        # Tests that a project template is not modified when used, and
+        # can therefore be used in subsequent reconfigurations.
+        in_repo_conf = textwrap.dedent(
+            """
+            - job:
+                name: project-test1
+            - project-template:
+                name: some-jobs
+                tenant-one-gate:
+                  jobs:
+                    - project-test1:
+                        required-projects:
+                          - org/project1
+            - project:
+                name: org/project
+                templates:
+                  - some-jobs
+            """)
+
+        file_dict = {'.zuul.yaml': in_repo_conf}
+        A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+                                           files=file_dict)
+        A.addApproval('Code-Review', 2)
+        self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
+        self.waitUntilSettled()
+        self.assertEqual(A.data['status'], 'MERGED')
+        self.fake_gerrit.addEvent(A.getChangeMergedEvent())
+        self.waitUntilSettled()
+        in_repo_conf = textwrap.dedent(
+            """
+            - project:
+                name: org/project1
+                templates:
+                  - some-jobs
+            """)
+        file_dict = {'.zuul.yaml': in_repo_conf}
+        B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B',
+                                           files=file_dict)
+        B.addApproval('Code-Review', 2)
+        self.fake_gerrit.addEvent(B.addApproval('Approved', 1))
+        self.waitUntilSettled()
+        self.assertEqual(B.data['status'], 'MERGED')
+
     def test_multi_repo(self):
         downstream_repo_conf = textwrap.dedent(
             """