Пример #1
0
    def test_init(self):
        resolwe = MagicMock()
        resource = MagicMock(endpoint='resolwe_endpoint',
                             query_endpoint=None,
                             query_method='GET')

        query = ResolweQuery(resolwe, resource, 'endpoint')
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, 'endpoint')

        query = ResolweQuery(resolwe, resource)
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, 'resolwe_endpoint')

        resource = MagicMock(endpoint='resolwe_endpoint',
                             query_endpoint='query_endpoint',
                             query_method='GET')

        query = ResolweQuery(resolwe, resource, 'endpoint')
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, 'endpoint')

        query = ResolweQuery(resolwe, resource)
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, 'query_endpoint')
Пример #2
0
    def test_search_undefined(self):
        resolwe = MagicMock()
        resource = MagicMock(full_search_paramater=None, query_endpoint="endpoint")
        query = ResolweQuery(resolwe, resource)

        # If ``full_search_paramater`` is not defined, raise NotImplemented error.
        with self.assertRaises(NotImplementedError):
            query.search("foo bar")
Пример #3
0
    def test_search(self):
        resolwe = MagicMock()
        resource = MagicMock(full_search_paramater='text',
                             query_endpoint='endpoint',
                             query_method='GET')
        query = ResolweQuery(resolwe, resource)

        new_query = query.search('foobar')
        self.assertEqual(
            list(new_query._filters.items()),
            list({'text': ['foobar']}.items()),
        )
Пример #4
0
    def test_search(self):
        resolwe = MagicMock()
        resource = MagicMock(
            full_search_paramater="text", query_endpoint="endpoint", query_method="GET"
        )
        query = ResolweQuery(resolwe, resource)

        new_query = query.search("foobar")
        self.assertEqual(
            list(new_query._filters.items()),
            list({"text": ["foobar"]}.items()),
        )
Пример #5
0
    def test_init(self):
        resolwe = MagicMock()
        resource = MagicMock(
            endpoint="resolwe_endpoint", query_endpoint=None, query_method="GET"
        )

        query = ResolweQuery(resolwe, resource)
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, "resolwe_endpoint")

        resource = MagicMock(
            endpoint="resolwe_endpoint",
            query_endpoint="query_endpoint",
            query_method="GET",
        )

        query = ResolweQuery(resolwe, resource)
        self.assertEqual(query.resolwe, resolwe)
        self.assertEqual(query.resource, resource)
        self.assertEqual(query.endpoint, "query_endpoint")