def test_query_empty(self):
     request = QueryRequest()
     transaction = QueryTransaction()
     # Make sure that prepare and commit do not throw an exception.
     transaction.prepare(request)
     transaction.commit(self._trie,
                        self._get_blessed_version(),
                        self._store)
 def test_query(self):
     some_query = Query()
     some_query.namePrefix = '/some_dir'
     some_query.maxTokens = 10
     some_other_query = Query()
     some_other_query.namePrefix = '/some_dir/some_token_0'
     some_other_query.maxTokens = 100
     request = QueryRequest()
     request.queries = [some_query, some_other_query]
     transaction = QueryTransaction()
     transaction.prepare(request)
     response = transaction.commit(self._trie, self._get_blessed_version(),
                                   self._store)
     self.assertEqual(2, len(response.tokens))
     self.assertEqual(10, len(response.tokens[0]))
     for token in response.tokens[0]:
         self.assertTrue(token.name.startswith('/some_dir'))
         self.assertEqual(9, token.priority)
     self.assertEqual(11, len(response.tokens[1]))
     for token in response.tokens[1]:
         self.assertTrue(token.name.startswith('/some_dir/some_token_0'))
 def test_query_empty(self):
     request = QueryRequest()
     transaction = QueryTransaction()
     # Make sure that prepare and commit do not throw an exception.
     transaction.prepare(request)
     transaction.commit(self._trie, self._get_blessed_version(),
                        self._store)
 def test_query(self):
     some_query = Query()
     some_query.namePrefix = '/some_dir'
     some_query.maxTokens = 10
     some_other_query = Query()
     some_other_query.namePrefix = '/some_dir/some_token_0'
     some_other_query.maxTokens = 100
     request = QueryRequest()
     request.queries = [some_query, some_other_query]
     transaction = QueryTransaction()
     transaction.prepare(request)
     response = transaction.commit(self._trie,
                                   self._get_blessed_version(),
                                   self._store)
     self.assertEqual(2, len(response.tokens))
     self.assertEqual(10, len(response.tokens[0]))
     for token in response.tokens[0]:
         self.assertTrue(token.name.startswith('/some_dir'))
         self.assertEqual(9, token.priority)
     self.assertEqual(11, len(response.tokens[1]))
     for token in response.tokens[1]:
         self.assertTrue(token.name.startswith('/some_dir/some_token_0'))