Skip to content

Commit

Permalink
add etm_simple_updatetestresult.py showing using the OSLC APIs to cre…
Browse files Browse the repository at this point in the history
…ate a new test result
  • Loading branch information
barny committed Oct 9, 2023
1 parent 9f3c161 commit 69fc740
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 4 deletions.
17 changes: 17 additions & 0 deletions elmclient/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,19 @@ def report_type_system( self ):
rows.append( [shortname,k,qcdetails[k]])
# print in a nice table with equal length columns
report += utils.print_in_html(rows,['Short Name', 'URI', 'Query Capability URI'])

report += "<H2>Project Factory Resource Types, short name and URI</H2>\n"
factorydetails = self.get_factory_uris()
rows = []
for k in sorted(factorydetails.keys()):
shortname = k.split('#')[-1]
shortname += " (default)" if self.default_query_resource is not None and k==rdfxml.tag_to_uri(self.default_query_resource) else ""
rows.append( [shortname,k,factorydetails[k]])
# print in a nice table with equal length columns
report += utils.print_in_html(rows,['Short Name', 'URI', 'Query Capability URI'])

report += self.textreport()

rows = []
for prefix in sorted(rdfxml.RDF_DEFAULT_PREFIX.keys()):
rows.append([prefix,rdfxml.RDF_DEFAULT_PREFIX[prefix]] )
Expand Down Expand Up @@ -139,6 +151,11 @@ def get_factory_uri(self,resource_type=None,context=None, return_shapes=False):
resource_type = resource_type or context.default_query_resource
return self.app.get_factory_uri_from_xml(factoriesxml=context.get_services_xml(), resource_type=resource_type,context=context, return_shapes=return_shapes)

def get_factory_uris(self,resource_type=None,context=None):
context = context or self
resource_type = resource_type or context.default_query_resource
return self.app.get_factory_uris_from_xml(factoriesxml=context.get_services_xml(),context=context)

def load_type_from_resource_shape(self, el):
raise Exception( "This must be provided by the inheriting class!" )

Expand Down
3 changes: 2 additions & 1 deletion elmclient/_qm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from . import rdfxml
from . import server
from . import utils
from . import _qmrestapi

#################################################################################################

Expand All @@ -29,7 +30,7 @@
#################################################################################################


class _QMProject(_project._Project):
class _QMProject(_project._Project, _qmrestapi.QM_REST_API_Mixin):
# A QM project
def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defaultinit=True):
super().__init__(name, project_uri, app, is_optin,singlemode,defaultinit=defaultinit)
Expand Down
42 changes: 42 additions & 0 deletions elmclient/_qmrestapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##
## © Copyright 2021- IBM Inc. All rights reserved
# SPDX-License-Identifier: MIT
##

# this is a start of implementing the ETM REST API - it's very incomplete!

import logging

import lxml.etree as ET

from . import rdfxml
from . import utils

logger = logging.getLogger(__name__)

#################################################################################################

class QM_REST_API_Mixin():
def __init__(self,*args,**kwargs):
self.typesystem_loaded = False
self.has_typesystem=True
self.clear_typesystem()
self.alias = None

def get_alias( self ):
if not self.alias:
# GET the alias
projects_x = self.execute_get_rdf_xml( f"service/com.ibm.rqm.integration.service.IIntegrationService/projects" )
self.alias = rdfxml.xmlrdf_get_resource_text( projects_x, f".//atom:entry/atom:title[.='{self.name}']/../atom:content/qm_ns2:project/qm_ns2:alias" )
# print( f"{self.alias=}" )
return self.alias

def find_testplan( self, name ):
pass

def find_testcase( self, name ):
pass

def find_testexecturionrecord( self, name ):
pass

Loading

0 comments on commit 69fc740

Please sign in to comment.