Beispiel #1
0
    def test_search(self):
        """Test the search utility."""
        def is_venture2(ci):
            return ci.uid == 'br-2'

        self.assertEqual(breadth_first_search_ci(self.server_b, is_venture2),
                         (self.venture2, True))

        self.assertEqual(breadth_first_search_ci(self.server_a, is_venture2),
                         (None, None))
Beispiel #2
0
    def test_search(self):
        """Test the search utility."""

        def is_venture2(ci):
            return ci.uid == 'br-2'

        self.assertEqual(
            breadth_first_search_ci(self.server_b, is_venture2),
            (self.venture2, True)
        )

        self.assertEqual(
            breadth_first_search_ci(self.server_a, is_venture2),
            (None, None)
        )
Beispiel #3
0
    def dehydrate(self, bundle, **kwargs):
        def get_owners(ci):
            owners = CIOwner.objects.filter(ciownership__type=self.owner_type, ciownership__ci=ci)
            result = []
            for owner in owners:
                result.append(self.dehydrate_related(bundle, self.get_related_resource(owner)))
            return result

        if self.effective:
            found, result = breadth_first_search_ci(bundle.obj, get_owners)
            return result
        else:
            return get_owners(bundle.obj)
Beispiel #4
0
    def dehydrate(self, bundle, **kwargs):
        def get_owners(ci):
            owners = CIOwner.objects.filter(
                ciownership__type=self.owner_type,
                ciownership__ci=ci,
            )
            result = []
            for owner in owners:
                result.append(
                    self.dehydrate_related(bundle,
                                           self.get_related_resource(owner)))
            return result

        if self.effective:
            found, result = breadth_first_search_ci(bundle.obj, get_owners)
            return result
        else:
            return get_owners(bundle.obj)