|
21 | 21 | """
|
22 | 22 |
|
23 | 23 | Shows how to use the TestLinkAPIGeneric.
|
24 |
| -- does same steps as Example TestLinkAPI in TestLinkExample.py |
| 24 | +- does equal things as Example TestLinkAPI in TestLinkExample.py |
25 | 25 |
|
26 | 26 | => Counts and lists the Projects
|
27 | 27 | => Create a new Project with the following structure:
|
|
81 | 81 | print "Error with the devKey."
|
82 | 82 | sys.exit(-1)
|
83 | 83 |
|
84 |
| -# NOT GENERIC |
85 |
| -#print "Number of Projects in TestLink: %s " % (myTestLink.countProjects(),) |
86 |
| -# print "" |
87 |
| -# myTestLink.listProjects() |
88 |
| -# print "" |
89 |
| -# GENERIC |
90 | 84 | print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())
|
91 | 85 | print ""
|
92 | 86 | for project in myTestLink.getProjects():
|
93 | 87 | print "Name: %(name)s ID: %(id)s " % project
|
94 | 88 | print ""
|
95 | 89 |
|
96 |
| - |
97 | 90 | # # Creates the project
|
98 |
| -# NOT GENERIC |
99 |
| -# newProject = myTestLink.createTestProject(NEWPROJECT, "NPROAPI", |
100 |
| -# "notes=This is a Project created with the API", "active=1", "public=1", |
101 |
| -# "options=requirementsEnabled:0,testPriorityEnabled:1,automationEnabled:1,inventoryEnabled:0") |
102 |
| -# GENERIC |
103 | 91 | newProject = myTestLink.createTestProject(NEWPROJECT, 'GPROAPI',
|
104 | 92 | notes='This is a Project created with the Generic API', active=1, public=1,
|
105 |
| - options={ 'requirementsEnabled' : 0, 'testPriorityEnabled' : 1, |
106 |
| - 'automationEnabled' : 1, 'inventoryEnabled' : 0}) |
| 93 | + options={'requirementsEnabled' : 1, 'testPriorityEnabled' : 1, |
| 94 | + 'automationEnabled' : 1, 'inventoryEnabled' : 1}) |
107 | 95 | print(newProject)
|
108 | 96 | isOk = newProject[0]['message']
|
109 | 97 | if isOk=="Success!":
|
|
113 | 101 | print "Error creating the project '%s': %s " % (NEWPROJECT,isOk)
|
114 | 102 | sys.exit(-1)
|
115 | 103 |
|
116 |
| -# # Creates the test plan |
117 |
| -# newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT, |
118 |
| -# "notes=New TestPlan created with the API","active=1", "public=1") |
119 |
| -# isOk = newTestPlan[0]['message'] |
120 |
| -# if isOk=="Success!": |
121 |
| -# newTestPlanID = newTestPlan[0]['id'] |
122 |
| -# print "New Test Plan '%s' - id: %s" % (NEWTESTPLAN,newTestPlanID) |
123 |
| -# else: |
124 |
| -# print "Error creating the Test Plan '%s': %s " % (NEWTESTPLAN, isOk) |
125 |
| -# sys.exit(-1) |
126 |
| -# |
127 |
| -# #Creates the test Suite A |
128 |
| -# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_A, |
129 |
| -# "Details of the Test Suite A") |
130 |
| -# isOk = newTestSuite[0]['message'] |
131 |
| -# if isOk=="ok": |
132 |
| -# newTestSuiteID = newTestSuite[0]['id'] |
133 |
| -# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID) |
134 |
| -# else: |
135 |
| -# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_A, isOk) |
136 |
| -# sys.exit(-1) |
137 |
| -# |
138 |
| -# FirstLevelID = newTestSuiteID |
139 |
| -# |
140 |
| -# #Creates the test Suite B |
141 |
| -# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_B, |
142 |
| -# "Details of the Test Suite B") |
143 |
| -# isOk = newTestSuite[0]['message'] |
144 |
| -# if isOk=="ok": |
145 |
| -# TestSuiteID_B = newTestSuite[0]['id'] |
146 |
| -# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, TestSuiteID_B) |
147 |
| -# else: |
148 |
| -# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_B, isOk) |
149 |
| -# sys.exit(-1) |
150 |
| -# |
151 |
| -# #Creates the test Suite AA |
152 |
| -# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA, |
153 |
| -# "Details of the Test Suite AA","parentid="+FirstLevelID) |
154 |
| -# isOk = newTestSuite[0]['message'] |
155 |
| -# if isOk=="ok": |
156 |
| -# TestSuiteID_AA = newTestSuite[0]['id'] |
157 |
| -# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, TestSuiteID_AA) |
158 |
| -# else: |
159 |
| -# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_AA, isOk) |
160 |
| -# sys.exit(-1) |
161 |
| -# |
162 |
| -# MANUAL = 1 |
163 |
| -# AUTOMATED = 2 |
164 |
| -# |
165 |
| -# #Creates the test case TC_AA |
166 |
| -# myTestLink.initStep("Step action 1", "Step result 1", MANUAL) |
167 |
| -# myTestLink.appendStep("Step action 2", "Step result 2", MANUAL) |
168 |
| -# myTestLink.appendStep("Step action 3", "Step result 3", MANUAL) |
169 |
| -# myTestLink.appendStep("Step action 4", "Step result 4", MANUAL) |
170 |
| -# myTestLink.appendStep("Step action 5", "Step result 5", MANUAL) |
171 |
| -# |
172 |
| -# newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA, |
173 |
| -# newProjectID, "admin", "This is the summary of the Test Case AA", |
174 |
| -# "preconditions=these are the preconditions") |
175 |
| -# isOk = newTestCase[0]['message'] |
176 |
| -# if isOk=="Success!": |
177 |
| -# newTestCaseID = newTestCase[0]['id'] |
178 |
| -# print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID) |
179 |
| -# else: |
180 |
| -# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk) |
181 |
| -# sys.exit(-1) |
182 |
| -# |
183 |
| -# #Creates the test case TC_B |
184 |
| -# myTestLink.initStep("Step action 1", "Step result 1", AUTOMATED) |
185 |
| -# myTestLink.appendStep("Step action 2", "Step result 2", AUTOMATED) |
186 |
| -# myTestLink.appendStep("Step action 3", "Step result 3", AUTOMATED) |
187 |
| -# myTestLink.appendStep("Step action 4", "Step result 4", AUTOMATED) |
188 |
| -# myTestLink.appendStep("Step action 5", "Step result 5", AUTOMATED) |
189 |
| -# |
190 |
| -# newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B, |
191 |
| -# newProjectID, "admin", "This is the summary of the Test Case B", |
192 |
| -# "preconditions=these are the preconditions", |
193 |
| -# "executiontype=%i" % AUTOMATED) |
194 |
| -# isOk = newTestCase[0]['message'] |
195 |
| -# if isOk=="Success!": |
196 |
| -# newTestCaseID = newTestCase[0]['id'] |
197 |
| -# print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID) |
198 |
| -# else: |
199 |
| -# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk) |
200 |
| -# sys.exit(-1) |
| 104 | +# Creates the test plan |
| 105 | +newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT, |
| 106 | + notes='New TestPlan created with the API',active=1, public=1) |
| 107 | +isOk = newTestPlan[0]['message'] |
| 108 | +if isOk=="Success!": |
| 109 | + newTestPlanID = newTestPlan[0]['id'] |
| 110 | + print "New Test Plan '%s' - id: %s" % (NEWTESTPLAN,newTestPlanID) |
| 111 | +else: |
| 112 | + print "Error creating the Test Plan '%s': %s " % (NEWTESTPLAN, isOk) |
| 113 | + sys.exit(-1) |
| 114 | + |
| 115 | +#Creates the test Suite A |
| 116 | +newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_A, |
| 117 | + "Details of the Test Suite A") |
| 118 | +isOk = newTestSuite[0]['message'] |
| 119 | +if isOk=="ok": |
| 120 | + newTestSuiteID = newTestSuite[0]['id'] |
| 121 | + print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID) |
| 122 | +else: |
| 123 | + print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_A, isOk) |
| 124 | + sys.exit(-1) |
| 125 | + |
| 126 | +FirstLevelID = newTestSuiteID |
| 127 | + |
| 128 | +#Creates the test Suite B |
| 129 | +newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_B, |
| 130 | + "Details of the Test Suite B") |
| 131 | +isOk = newTestSuite[0]['message'] |
| 132 | +if isOk=="ok": |
| 133 | + TestSuiteID_B = newTestSuite[0]['id'] |
| 134 | + print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, TestSuiteID_B) |
| 135 | +else: |
| 136 | + print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_B, isOk) |
| 137 | + sys.exit(-1) |
| 138 | + |
| 139 | +#Creates the test Suite AA |
| 140 | +newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA, |
| 141 | + "Details of the Test Suite AA",parentid=FirstLevelID) |
| 142 | +isOk = newTestSuite[0]['message'] |
| 143 | +if isOk=="ok": |
| 144 | + TestSuiteID_AA = newTestSuite[0]['id'] |
| 145 | + print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, TestSuiteID_AA) |
| 146 | +else: |
| 147 | + print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_AA, isOk) |
| 148 | + sys.exit(-1) |
| 149 | + |
| 150 | +MANUAL = 1 |
| 151 | +AUTOMATED = 2 |
201 | 152 | #
|
| 153 | +# #Creates the test case TC_AA |
| 154 | +steps_tc_aa = [ |
| 155 | + {'step_number' : 1, 'actions' : "Step action 1 - aa" , |
| 156 | + 'expected_results' : "Step result 1 - aa", 'execution_type' : MANUAL}, |
| 157 | + {'step_number' : 2, 'actions' : "Step action 2 - aa" , |
| 158 | + 'expected_results' : "Step result 2 - aa", 'execution_type' : MANUAL}, |
| 159 | + {'step_number' : 3, 'actions' : "Step action 3 - aa" , |
| 160 | + 'expected_results' : "Step result 3 - aa", 'execution_type' : MANUAL}, |
| 161 | + {'step_number' : 4, 'actions' : "Step action 4 - aa" , |
| 162 | + 'expected_results' : "Step result 4 - aa", 'execution_type' : MANUAL}, |
| 163 | + {'step_number' : 5, 'actions' : "Step action 5 - aa" , |
| 164 | + 'expected_results' : "Step result 5 - aa", 'execution_type' : MANUAL} |
| 165 | + ] |
| 166 | +newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA, |
| 167 | + newProjectID, "admin", "This is the summary of the Test Case AA", |
| 168 | + steps_tc_aa, preconditions='these are the preconditions') |
| 169 | +isOk = newTestCase[0]['message'] |
| 170 | +if isOk=="Success!": |
| 171 | + newTestCaseID = newTestCase[0]['id'] |
| 172 | + print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID) |
| 173 | +else: |
| 174 | + print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk) |
| 175 | + sys.exit(-1) |
| 176 | + |
| 177 | +#Creates the test case TC_B |
| 178 | +steps_tc_b = [ |
| 179 | + {'step_number' : 1, 'actions' : "Step action 1 -b " , |
| 180 | + 'expected_results' : "Step result 1 - b", 'execution_type' : AUTOMATED}, |
| 181 | + {'step_number' : 2, 'actions' : "Step action 2 -b " , |
| 182 | + 'expected_results' : "Step result 2 - b", 'execution_type' : AUTOMATED}, |
| 183 | + {'step_number' : 3, 'actions' : "Step action 3 -b " , |
| 184 | + 'expected_results' : "Step result 3 - b", 'execution_type' : AUTOMATED}, |
| 185 | + {'step_number' : 4, 'actions' : "Step action 4 -b " , |
| 186 | + 'expected_results' : "Step result 4 - b", 'execution_type' : AUTOMATED}, |
| 187 | + {'step_number' : 5, 'actions' : "Step action 5 -b " , |
| 188 | + 'expected_results' : "Step result 5 - b", 'execution_type' : AUTOMATED}] |
| 189 | + |
| 190 | +newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B, |
| 191 | + newProjectID, "admin", "This is the summary of the Test Case B", |
| 192 | + steps_tc_b, preconditions='these are the preconditions', |
| 193 | + executiontype=AUTOMATED) |
| 194 | +isOk = newTestCase[0]['message'] |
| 195 | +if isOk=="Success!": |
| 196 | + newTestCaseID = newTestCase[0]['id'] |
| 197 | + print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID) |
| 198 | +else: |
| 199 | + print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk) |
| 200 | + sys.exit(-1) |
| 201 | + |
202 | 202 | print ""
|
203 |
| -# NOT GENERIC |
204 |
| -# print "Number of Projects in TestLink: %s " % (myTestLink.countProjects(),) |
205 |
| -# print "" |
206 |
| -# myTestLink.listProjects() |
207 |
| -# GENERIC |
208 | 203 | print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())
|
209 | 204 | print ""
|
210 | 205 | for project in myTestLink.getProjects():
|
|
0 commit comments