Best Python code snippet using autotest_python
resource_lib.py
Source:resource_lib.py  
...451        self.fixed_entry = None452        self.unfixed_name = None453        self.related_manager = None454        if fixed_entry is not None:455            self._set_fixed_entry(fixed_entry)456            entry_uri_arg = self.fixed_entry._uri_args().values()[0]457            self._query_params[self.fixed_name] = entry_uri_arg458    def _set_fixed_entry(self, entry):459        """Set the fixed entry for this collection.460        The entry must be an instance of one of the related entry classes.  This461        method must be called before a relationship is used.  It gets called462        either from the constructor (when collections are instantiated from463        other resource handling code) or from read_query_parameters() (when a464        request is made directly for the collection.465        """466        names = self.related_classes.keys()467        if isinstance(entry, self.related_classes[names[0]]):468            self.fixed_name, self.unfixed_name = names469        else:470            assert isinstance(entry, self.related_classes[names[1]])471            self.unfixed_name, self.fixed_name = names472        self.fixed_entry = entry473        self.unfixed_class = self.related_classes[self.unfixed_name]474        self.related_manager = self.entry_class._get_related_manager(475                entry.instance)476    def _query_parameters_accepted(self):477        return [(name, 'Show relationships for this %s' % entry_class.__name__)478                for name, entry_class479                in self.related_classes.iteritems()]480    def _resolve_query_param(self, name, uri_arg):481        entry_class = self.related_classes[name]482        return entry_class.from_uri_args(self._request, uri_arg)483    def read_query_parameters(self, query_params):484        super(RelationshipCollection, self).read_query_parameters(query_params)485        if not self._query_params:486            raise exceptions.BadRequest(487                    'You must specify one of the parameters %s and %s'488                    % tuple(self.related_classes.keys()))489        query_items = self._query_params.items()490        fixed_entry = self._resolve_query_param(*query_items[0])491        self._set_fixed_entry(fixed_entry)492        if len(query_items) > 1:493            other_fixed_entry = self._resolve_query_param(*query_items[1])494            self.related_manager = self.related_manager.filter(495                    pk=other_fixed_entry.instance.id)496    def _entry_from_instance(self, instance):497        unfixed_entry = self.unfixed_class(self._request, instance)498        entries = {self.fixed_name: self.fixed_entry,499                   self.unfixed_name: unfixed_entry}500        return self.entry_class(**entries)501    def _fresh_queryset(self):...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
