示例#1
0
    def test_query_and_own(self):
        some_token = self._trie['/some_dir/some_token_0']
        some_token.owner = 'some_owner'
        some_token.expirationTime = 10  # in the past
        some_token = self._trie['/some_dir/some_token_1']
        some_token.owner = 'some_owner'
        some_token.expirationTime = sys.maxint  # in the future
        some_query = Query()
        some_query.namePrefix = ''
        some_query.maxTokens = 200
        request = QueryAndOwnRequest()
        request.owner = 'some_other_owner'
        request.expirationTime = sys.maxint
        request.query = some_query
        transaction = QueryAndOwnTransaction()
        transaction.prepare(request)
        response = transaction.commit(self._trie, self._get_blessed_version(),
                                      self._store)

        # Should have owned all tokens but two: the blessed version and the one
        # token that is already owned.
        self.assertEqual(len(self._trie) - 2, len(response.tokens))
        for token in response.tokens:
            self.assertEquals('some_other_owner', token.owner)
            self.assertEquals(sys.maxint, token.expirationTime)
示例#2
0
    def test_query_and_own(self):
        some_token = self._trie['/some_dir/some_token_0']
        some_token.owner = 'some_owner'
        some_token.expirationTime = 10  # in the past
        some_token = self._trie['/some_dir/some_token_1']
        some_token.owner = 'some_owner'
        some_token.expirationTime = sys.maxint  # in the future
        some_query = Query()
        some_query.namePrefix = ''
        some_query.maxTokens = 200
        request = QueryAndOwnRequest()
        request.owner = 'some_other_owner'
        request.expirationTime = sys.maxint
        request.query = some_query
        transaction = QueryAndOwnTransaction()
        transaction.prepare(request)
        response = transaction.commit(self._trie,
                                      self._get_blessed_version(),
                                      self._store)

        # Should have owned all tokens but two: the blessed version and the one
        # token that is already owned.
        self.assertEqual(len(self._trie) - 2, len(response.tokens))
        for token in response.tokens:
            self.assertEquals('some_other_owner', token.owner)
            self.assertEquals(sys.maxint, token.expirationTime)
示例#3
0
 def test_query_and_own_empty(self):
     request = QueryAndOwnRequest()
     transaction = QueryAndOwnTransaction()
     # Make sure that prepare and commit do not throw an exception.
     transaction.prepare(request)
     transaction.commit(self._trie, self._get_blessed_version(),
                        self._store)
示例#4
0
 def test_query_and_own_empty(self):
     request = QueryAndOwnRequest()
     transaction = QueryAndOwnTransaction()
     # Make sure that prepare and commit do not throw an exception.
     transaction.prepare(request)
     transaction.commit(self._trie,
                        self._get_blessed_version(),
                        self._store)