def _remove(self, bugs): """ Detach provided bugs from the test case """ log.info(u"Detaching {0} from {1}".format(listed(bugs), self._identifier)) data = [bug.bug for bug in bugs] log.data(pretty(data)) self._server.TestCaseRun.detach_bug(self.id, data)
def _fetch(self, inject=None): """ Get the missing test plan type data """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.info("Processing PlanType ID#{0} inject".format(inject["id"])) # Search by test plan type id elif self._id is not NitrateNone: try: log.info("Fetching test plan type " + self.identifier) inject = self._server.TestPlan.get_plan_type(self.id) except xmlrpclib.Fault as error: log.debug(error) raise NitrateError( "Cannot find test plan type for " + self.identifier) # Search by test plan type name else: try: log.info(u"Fetching test plan type '{0}'".format(self.name)) inject = self._server.TestPlan.check_plan_type(self.name) except xmlrpclib.Fault as error: log.debug(error) raise NitrateError("PlanType '{0}' not found".format( self.name)) # Initialize data from the inject and index into cache log.debug("Initializing PlanType ID#{0}".format(inject["id"])) log.data(pretty(inject)) self._inject = inject self._id = inject["id"] self._name = inject["name"] self._index(self.name)
def _remove(self, bugs): """ Detach provided bugs from the test case """ log.info(u"Detaching {0} from {1}".format( listed(bugs), self._identifier)) data = [bug.bug for bug in bugs] log.data(pretty(data)) self._server.TestCaseRun.detach_bug(self.id, data)
def _add(self, testcases): """ Add given test cases to the test run """ # Short info about the action identifiers = [testcase.identifier for testcase in testcases] log.info("Adding {0} to {1}".format( listed(identifiers, "testcase", max=3), self._object.identifier)) # Prepare data and push data = [testcase.id for testcase in testcases] log.data(pretty(data)) try: self._server.TestRun.add_cases(self.id, data) # Handle duplicate entry errors by adding test cases one by one except xmlrpclib.Fault as error: if not "Duplicate entry" in unicode(error): raise log.warn(error) for id in data: try: self._server.TestRun.add_cases(self.id, id) except xmlrpclib.Fault: pass # RunCaseRuns will need update ---> erase current data self._object.caseruns._init()
def _add(self, bugs): """ Attach provided bugs to the test case """ log.info(u"Attaching {0} to {1}".format(listed(bugs), self._identifier)) data = [{"bug_id": bug.bug, "bug_system_id": bug.system, "case_run_id": self.id} for bug in bugs] log.data(pretty(data)) self._server.TestCaseRun.attach_bug(data) # Fetch again the whole bug list (to get the internal id) self._fetch()
def _fetch(self, inset=None): """ Fetch currently attached tags from the server """ # If data initialized from the inset ---> we're done if Container._fetch(self, inset): return log.info("Fetching tags for {0}".format(self._identifier)) injects = self._server.TestCase.get_tags(self.id) log.debug(pretty(injects)) self._current = set([Tag(inject) for inject in injects]) self._original = set(self._current)
def _fetch(self, inset=None): """ Fetch test runs from the server """ # If data initialized from the inset ---> we're done if Container._fetch(self, inset): return log.info("Fetching testruns for {0}".format(self._identifier)) injects = self._server.TestPlan.get_test_runs(self.id) log.data(pretty(injects)) self._current = set([TestRun(inject) for inject in injects]) self._original = set(self._current)
def _remove(self, testcases): """ Remove given test cases from the test run """ # Short info about the action identifiers = [testcase.identifier for testcase in testcases] log.info("Removing {0} from {1}".format(listed(identifiers, "testcase", max=3), self._object.identifier)) data = [testcase.id for testcase in testcases] log.data(pretty(data)) self._server.TestRun.remove_cases(self.id, data) # RunCaseRuns will need update ---> erase current data self._object.caseruns._init()
def _remove(self, testcases): """ Remove given test cases from the test run """ # Short info about the action identifiers = [testcase.identifier for testcase in testcases] log.info("Removing {0} from {1}".format( listed(identifiers, "testcase", max=3), self._object.identifier)) data = [testcase.id for testcase in testcases] log.data(pretty(data)) self._server.TestRun.remove_cases(self.id, data) # RunCaseRuns will need update ---> erase current data self._object.caseruns._init()
def _add(self, bugs): """ Attach provided bugs to the test case """ log.info(u"Attaching {0} to {1}".format(listed(bugs), self._identifier)) data = [{ "bug_id": bug.bug, "bug_system_id": bug.system, "case_run_id": self.id } for bug in bugs] log.data(pretty(data)) self._server.TestCaseRun.attach_bug(data) # Fetch again the whole bug list (to get the internal id) self._fetch()
def multicall_end(): """ Execute xmlrpc call queue and exit MultiCall mode """ log.info("Ending multicall session, sending to the server...") response = Nitrate._multicall_proxy() log.data("Server response:") entries = 0 for entry in response: log.data(pretty(entry)) entries += 1 Nitrate._multicall_proxy = None Nitrate._requests += 1 log.info("Multicall session finished, {0} completed".format( listed(entries, "update"))) return response
def _fetch(self, inject=None): """ Fetch user data from the server """ Nitrate._fetch(self, inject) if inject is None: # Search by id if self._id is not NitrateNone: try: log.info("Fetching user " + self.identifier) inject = self._server.User.filter({"id": self.id})[0] except IndexError: raise NitrateError( "Cannot find user for " + self.identifier) # Search by login elif self._login is not NitrateNone: try: log.info( "Fetching user for login '{0}'".format(self.login)) inject = self._server.User.filter( {"username": self.login})[0] except IndexError: raise NitrateError("No user found for login '{0}'".format( self.login)) # Search by email elif self._email is not NitrateNone: try: log.info("Fetching user for email '{0}'".format( self.email)) inject = self._server.User.filter({"email": self.email})[0] except IndexError: raise NitrateError("No user found for email '{0}'".format( self.email)) # Otherwise initialize to the current user else: log.info("Fetching the current user") inject = self._server.User.get_me() self._index("i-am-current-user") # Initialize data from the inject and index into cache log.debug("Initializing user UID#{0}".format(inject["id"])) log.data(pretty(inject)) self._inject = inject self._id = inject["id"] self._login = inject["username"] self._email = inject["email"] if inject["first_name"] and inject["last_name"]: self._name = inject["first_name"] + " " + inject["last_name"] else: self._name = None self._index(self.login, self.email)
def _fetch(self, inset=None): """ Save cache timestamp and initialize from inset if given """ Nitrate._fetch(self) # Create copies of the initial set (if given) if inset is not None: log.debug("Initializing {0} for {1} from the inset".format(self.__class__.__name__, self._identifier)) log.debug(pretty(inset)) self._current = set(inset) self._original = set(inset) # Cache into container class if config.get_cache_level() >= config.CACHE_OBJECTS: self.__class__._cache[self._id] = self # Return True if the data are already initialized return inset is not None
def _fetch(self, inject=None): """ Fetch product data from the server """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.debug("Initializing Product ID#{0}".format(inject["id"])) log.data(pretty(inject)) self._id = inject["id"] self._name = inject["name"] # Search by product id elif self._id is not NitrateNone: try: log.info("Fetching product " + self.identifier) inject = self._server.Product.filter({'id': self.id})[0] log.debug("Initializing product " + self.identifier) log.data(pretty(inject)) self._inject = inject self._name = inject["name"] except IndexError: raise NitrateError( "Cannot find product for " + self.identifier) # Search by product name else: try: log.info(u"Fetching product '{0}'".format(self.name)) inject = self._server.Product.filter({'name': self.name})[0] log.debug(u"Initializing product '{0}'".format(self.name)) log.data(pretty(inject)) self._inject = inject self._id = inject["id"] except IndexError: raise NitrateError( "Cannot find product for '{0}'".format(self.name)) # Index the fetched object into cache self._index(self.name)
def _fetch(self, inject=None): """ Fetch tag data from the server """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.debug("Initializing Tag ID#{0}".format(inject["id"])) log.data(pretty(inject)) self._id = inject["id"] self._name = inject["name"] # Search by tag id elif self._id is not NitrateNone: try: log.info("Fetching tag " + self.identifier) inject = self._server.Tag.get_tags({'ids': [self.id]}) log.debug("Initializing tag " + self.identifier) log.data(pretty(inject)) self._inject = inject self._name = inject[0]["name"] except IndexError: raise NitrateError( "Cannot find tag for {0}".format(self.identifier)) # Search by tag name else: try: log.info(u"Fetching tag '{0}'".format(self.name)) inject = self._server.Tag.get_tags({'names': [self.name]}) log.debug(u"Initializing tag '{0}'".format(self.name)) log.data(pretty(inject)) self._inject = inject self._id = inject[0]["id"] except IndexError: raise NitrateError( "Cannot find tag '{0}'".format(self.name)) # Index the fetched object into cache self._index(self.name)
def _fetch(self, inset=None): """ Save cache timestamp and initialize from inset if given """ Nitrate._fetch(self) # Create copies of the initial set (if given) if inset is not None: log.debug("Initializing {0} for {1} from the inset".format( self.__class__.__name__, self._identifier)) log.debug(pretty(inset)) self._current = set(inset) self._original = set(inset) # Cache into container class if config.get_cache_level() >= config.CACHE_OBJECTS: self.__class__._cache[self._id] = self # Return True if the data are already initialized return inset is not None
def _fetch(self, inset=None): """ Fetch case plans from the server """ # If data initialized from the inset ---> we're done if Container._fetch(self, inset): return # Fetch test case plans from the server using multicall log.info("Fetching case plans for {0}".format(self._identifier)) multicall = xmlrpclib.MultiCall(self._server) for testcase in self._object.testcases._items: multicall.TestCasePlan.get(testcase.id, self._object.id) injects = [inject for inject in multicall()] log.data(pretty(injects)) # And finally create the initial object set self._current = set([CasePlan(inject) for inject in injects]) self._original = set(self._current)
def _fetch(self, inject=None): """ Get the missing build data """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.info("Processing build ID#{0} inject".format( inject["build_id"])) # Search by build id elif self._id is not NitrateNone: try: log.info("Fetching build " + self.identifier) inject = self._server.Build.get(self.id) except xmlrpclib.Fault as error: log.debug(error) raise NitrateError( "Cannot find build for " + self.identifier) # Search by build name and product else: try: log.info(u"Fetching build '{0}' of '{1}'".format( self.name, self.product.name)) inject = self._server.Build.check_build( self.name, self.product.id) self._id = inject["build_id"] except xmlrpclib.Fault as error: log.debug(error) raise NitrateError("Build '{0}' not found in '{1}'".format( self.name, self.product.name)) except KeyError: if "args" in inject: log.debug(inject["args"]) raise NitrateError("Build '{0}' not found in '{1}'".format( self.name, self.product.name)) # Initialize data from the inject and index into cache log.debug("Initializing Build ID#{0}".format(inject["build_id"])) log.data(pretty(inject)) self._inject = inject self._id = inject["build_id"] self._name = inject["name"] self._product = Product( {"id": inject["product_id"], "name": inject["product"]}) self._index("{0}---in---{1}".format(self.name, self.product.name))
def _fetch(self, inject=None): """ Fetch version data from the server """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.debug("Processing Version ID#{0} inject".format(inject["id"])) # Search by version id elif self._id is not NitrateNone: try: log.info("Fetching version {0}".format(self.identifier)) inject = self._server.Product.filter_versions( {'id': self.id})[0] except IndexError: raise NitrateError( "Cannot find version for {0}".format(self.identifier)) # Search by product and name else: try: log.info(u"Fetching version '{0}' of '{1}'".format( self.name, self.product.name)) inject = self._server.Product.filter_versions( {'product': self.product.id, 'value': self.name})[0] except IndexError: raise NitrateError( "Cannot find version for '{0}'".format(self.name)) # Initialize data from the inject and index into cache log.debug("Initializing Version ID#{0}".format(inject["id"])) log.data(pretty(inject)) self._inject = inject self._id = inject["id"] self._name = inject["value"] self._product = Product(inject["product_id"]) # Index by product name & version name (if product is cached) if self.product._name is not NitrateNone: self._index("{0}---in---{1}".format(self.name, self.product.name)) # Otherwise index by id only else: self._index()
def _fetch(self, inject=None): """ Get the missing category data """ Nitrate._fetch(self, inject) # Directly fetch from the initial object dict if inject is not None: log.info("Processing category ID#{0} inject".format(inject["id"])) # Search by category id elif self._id is not NitrateNone: try: log.info("Fetching category {0}".format(self.identifier)) inject = self._server.Product.get_category(self.id) except xmlrpclib.Fault as error: log.debug(error) raise NitrateError( "Cannot find category for " + self.identifier) # Search by category name and product else: try: log.info(u"Fetching category '{0}' of '{1}'".format( self.name, self.product.name)) inject = self._server.Product.check_category( self.name, self.product.id) except xmlrpclib.Fault as error: log.debug(error) raise NitrateError("Category '{0}' not found in" " '{1}'".format(self.name, self.product.name)) # Initialize data from the inject and index into cache log.debug("Initializing category ID#{0}".format(inject["id"])) log.data(pretty(inject)) self._inject = inject self._id = inject["id"] self._name = inject["name"] self._product = Product( {"id": inject["product_id"], "name": inject["product"]}) self._index("{0}---in---{1}".format(self.name, self.product.name))
def _add(self, testcases): """ Add given test cases to the test run """ # Short info about the action identifiers = [testcase.identifier for testcase in testcases] log.info("Adding {0} to {1}".format( listed(identifiers, "testcase", max=3), self._object.identifier)) # Prepare data and push data = [testcase.id for testcase in testcases] log.data(pretty(data)) try: self._server.TestRun.add_cases(self.id, data) # Handle duplicate entry errors by adding test cases one by one except xmlrpclib.Fault as error: if not "Duplicate entry" in six.u(error): raise log.warn(error) for id in data: try: self._server.TestRun.add_cases(self.id, id) except xmlrpclib.Fault: pass # RunCaseRuns will need update ---> erase current data self._object.caseruns._init()