Skip to content

Commit 69fc740

Browse files
committed
add etm_simple_updatetestresult.py showing using the OSLC APIs to create a new test result
1 parent 9f3c161 commit 69fc740

File tree

6 files changed

+408
-4
lines changed

6 files changed

+408
-4
lines changed

elmclient/_project.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,19 @@ def report_type_system( self ):
103103
rows.append( [shortname,k,qcdetails[k]])
104104
# print in a nice table with equal length columns
105105
report += utils.print_in_html(rows,['Short Name', 'URI', 'Query Capability URI'])
106+
107+
report += "<H2>Project Factory Resource Types, short name and URI</H2>\n"
108+
factorydetails = self.get_factory_uris()
109+
rows = []
110+
for k in sorted(factorydetails.keys()):
111+
shortname = k.split('#')[-1]
112+
shortname += " (default)" if self.default_query_resource is not None and k==rdfxml.tag_to_uri(self.default_query_resource) else ""
113+
rows.append( [shortname,k,factorydetails[k]])
114+
# print in a nice table with equal length columns
115+
report += utils.print_in_html(rows,['Short Name', 'URI', 'Query Capability URI'])
116+
106117
report += self.textreport()
118+
107119
rows = []
108120
for prefix in sorted(rdfxml.RDF_DEFAULT_PREFIX.keys()):
109121
rows.append([prefix,rdfxml.RDF_DEFAULT_PREFIX[prefix]] )
@@ -139,6 +151,11 @@ def get_factory_uri(self,resource_type=None,context=None, return_shapes=False):
139151
resource_type = resource_type or context.default_query_resource
140152
return self.app.get_factory_uri_from_xml(factoriesxml=context.get_services_xml(), resource_type=resource_type,context=context, return_shapes=return_shapes)
141153

154+
def get_factory_uris(self,resource_type=None,context=None):
155+
context = context or self
156+
resource_type = resource_type or context.default_query_resource
157+
return self.app.get_factory_uris_from_xml(factoriesxml=context.get_services_xml(),context=context)
158+
142159
def load_type_from_resource_shape(self, el):
143160
raise Exception( "This must be provided by the inheriting class!" )
144161

elmclient/_qm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from . import rdfxml
2222
from . import server
2323
from . import utils
24+
from . import _qmrestapi
2425

2526
#################################################################################################
2627

@@ -29,7 +30,7 @@
2930
#################################################################################################
3031

3132

32-
class _QMProject(_project._Project):
33+
class _QMProject(_project._Project, _qmrestapi.QM_REST_API_Mixin):
3334
# A QM project
3435
def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defaultinit=True):
3536
super().__init__(name, project_uri, app, is_optin,singlemode,defaultinit=defaultinit)

elmclient/_qmrestapi.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
##
2+
## © Copyright 2021- IBM Inc. All rights reserved
3+
# SPDX-License-Identifier: MIT
4+
##
5+
6+
# this is a start of implementing the ETM REST API - it's very incomplete!
7+
8+
import logging
9+
10+
import lxml.etree as ET
11+
12+
from . import rdfxml
13+
from . import utils
14+
15+
logger = logging.getLogger(__name__)
16+
17+
#################################################################################################
18+
19+
class QM_REST_API_Mixin():
20+
def __init__(self,*args,**kwargs):
21+
self.typesystem_loaded = False
22+
self.has_typesystem=True
23+
self.clear_typesystem()
24+
self.alias = None
25+
26+
def get_alias( self ):
27+
if not self.alias:
28+
# GET the alias
29+
projects_x = self.execute_get_rdf_xml( f"service/com.ibm.rqm.integration.service.IIntegrationService/projects" )
30+
self.alias = rdfxml.xmlrdf_get_resource_text( projects_x, f".//atom:entry/atom:title[.='{self.name}']/../atom:content/qm_ns2:project/qm_ns2:alias" )
31+
# print( f"{self.alias=}" )
32+
return self.alias
33+
34+
def find_testplan( self, name ):
35+
pass
36+
37+
def find_testcase( self, name ):
38+
pass
39+
40+
def find_testexecturionrecord( self, name ):
41+
pass
42+

0 commit comments

Comments
 (0)