Exemplo n.º 1
0
 def test_get(self):
     with patch.object(Document, 'get') as mock_method:
         doc = DocumentCollection(Mock())
         doc.get('collection_test', 'key1')
         mock_method.assert_called_with(kind='collections',
                                        collection='collection_test',
                                        key='key1')
Exemplo n.º 2
0
 def test_post(self):
     with patch.object(Document, 'post') as mock_method:
         doc = DocumentCollection(Mock())
         doc.post('collection_test', {'doc': 1})
         mock_method.assert_called_with(kind='collections',
                                        collection='collection_test',
                                        document={'doc': 1})
Exemplo n.º 3
0
 def test_list(self):
     with patch.object(Document, 'list') as mock_method:
         doc = DocumentCollection(Mock())
         doc.list('collection_test', 10, 1)
         mock_method.assert_called_with(kind='collections',
                                        collection='collection_test',
                                        per_page=10,
                                        page=1)
Exemplo n.º 4
0
 def test_clear(self):
     with patch.object(Document, 'clear') as mock_method:
         doc = DocumentCollection(Mock())
         query = [[{'field': 'name', 'operator': 'LIKE', 'value': 'test'}]]
         doc.clear('collection_test', query)
         mock_method.assert_called_with(kind='collections',
                                        collection='collection_test',
                                        query=query)
Exemplo n.º 5
0
 def test_search_with_pagination(self):
     with patch.object(Document, 'search') as mock_method:
         doc = DocumentCollection(Mock())
         query = [[{'field': 'name', 'operator': 'LIKE', 'value': 'test'}]]
         doc.search('collection_test', query, 20, 2)
         mock_method.assert_called_with(kind='collections',
                                        collection='collection_test',
                                        query=query,
                                        per_page=20,
                                        page=2)
Exemplo n.º 6
0
    def test_search_many_coll_with_pagination(self):
        doc = DocumentCollection(Mock())
        doc.make_request = Mock()
        collections = ['collection_test1', 'collection_test2']
        query = [[{'field': 'name', 'operator': 'LIKE', 'value': 'test'}]]
        doc.search_many_coll(collections, query, 20, 2)

        params = {
            'query': json.dumps(query),
            'per_page': 20,
            'collections': collections,
            'page': 2
        }
        doc.make_request.assert_called_once_with(method='GET',
                                                 uri='collections/search',
                                                 params=params)