Example #1
0
 def test_filter_entities_for_success(self):
     '''
     Call the filter test.
     '''
     workflow.filter_entities(self.resources, [], {})
     workflow.filter_entities(self.resources, [self.kind], {})
     workflow.filter_entities(self.resources, [], {'foo': 'bar'})
Example #2
0
 def test_filter_entities_for_success(self):
     '''
     Call the filter test.
     '''
     workflow.filter_entities(self.resources, [], {})
     workflow.filter_entities(self.resources, [self.kind], {})
     workflow.filter_entities(self.resources, [], {'foo': 'bar'})
Example #3
0
    def get(self, key):
        # retrieve (filter)
        try:
            if key == '' or key[-1] != '/':
                key += '/'

            categories, attributes = self.parse_filter()
            entities = workflow.get_entities_under_path(key, self.registry)
            result = workflow.filter_entities(entities, categories, attributes)

            self.render_entities(result, key)
        except AttributeError as attr:
            raise HTTPError(400, str(attr))
Example #4
0
    def test_filter_entities_for_sanity(self):
        '''
        Check if the filter operates correctly.
        '''
        # return all
        res = workflow.filter_entities(self.resources, [], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[1] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 3)

        # return just the two resources
        res = workflow.filter_entities(self.resources, [self.kind], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[1] in res)
        self.assertTrue(len(res) == 2)

        # return source and link
        res = workflow.filter_entities(self.resources, [], {'foo': 'bar'})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 2)

        # return just the source
        res = workflow.filter_entities(self.resources, [self.mixin], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(len(res) == 1)

        # return just the source and link
        res = workflow.filter_entities(self.resources, [self.mixin,
                                                        self.link_kind], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 2)

        # return just the link...
        res = workflow.filter_entities(self.resources, [self.kind],
                                       {'foo': 'bar'})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(len(res) == 1)
Example #5
0
    def test_filter_entities_for_sanity(self):
        '''
        Check if the filter operates correctly.
        '''
        # return all
        res = workflow.filter_entities(self.resources, [], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[1] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 3)

        # return just the two resources
        res = workflow.filter_entities(self.resources, [self.kind], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[1] in res)
        self.assertTrue(len(res) == 2)

        # return source and link
        res = workflow.filter_entities(self.resources, [], {'foo': 'bar'})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 2)

        # return just the source
        res = workflow.filter_entities(self.resources, [self.mixin], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(len(res) == 1)

        # return just the source and link
        res = workflow.filter_entities(self.resources,
                                       [self.mixin, self.link_kind], {})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(self.resources[2] in res)
        self.assertTrue(len(res) == 2)

        # return just the link...
        res = workflow.filter_entities(self.resources, [self.kind],
                                       {'foo': 'bar'})
        self.assertTrue(self.resources[0] in res)
        self.assertTrue(len(res) == 1)