Exemplo n.º 1
0
 def setUp(self):
     """Set up self._trie with 111 tokens, one of them a blessed version."""
     self._trie = pytrie.StringTrie()
     self._store = EphemeralStore()
     blessed_version = BlessedVersion(MasterHandler._BLESSED_VERSION,
                                      MasterHandler._MASTER_OWNER)
     for i in range(0, 10):
         some_token = Token(blessed_version.advance_version(),
                            '/some_dir/some_token_%d' % i,
                            priority=i,
                            data='some_data_%d' % i)
         self._trie[some_token.name] = some_token
         self._store.commit_tokens(updates=[some_token])
         for j in range(0, 10):
             some_other_token = Token(
                 blessed_version.advance_version(),
                 '/some_dir/some_token_%d/some_other_token_%d' % (i, j),
                 priority=j,
                 data='some_data_%d_%d' % (i, j))
             self._trie[some_other_token.name] = some_other_token
             self._store.commit_tokens(updates=[some_other_token])
     blessed_version.advance_version()
     self._trie[MasterHandler._BLESSED_VERSION] = blessed_version
     self._store.commit_tokens(updates=[blessed_version])
     self._check_version_uniqueness()
Exemplo n.º 2
0
 def setUp(self):
     """Set up self._trie with 111 tokens, one of them a blessed version."""
     self._trie = pytrie.StringTrie()
     self._store = EphemeralStore()
     blessed_version = BlessedVersion(MasterHandler._BLESSED_VERSION,
                                      MasterHandler._MASTER_OWNER)
     for i in range(0, 10):
         some_token = Token(blessed_version.advance_version(),
                            '/some_dir/some_token_%d' % i,
                            priority=i,
                            data='some_data_%d' % i)
         self._trie[some_token.name] = some_token
         self._store.commit_tokens(updates=[some_token])
         for j in range(0, 10):
             some_other_token = Token(
                 blessed_version.advance_version(),
                 '/some_dir/some_token_%d/some_other_token_%d' % (i, j),
                 priority=j,
                 data='some_data_%d_%d' % (i, j))
             self._trie[some_other_token.name] = some_other_token
             self._store.commit_tokens(updates=[some_other_token])
     blessed_version.advance_version()
     self._trie[MasterHandler._BLESSED_VERSION] = blessed_version
     self._store.commit_tokens(updates=[blessed_version])
     self._check_version_uniqueness()
Exemplo n.º 3
0
 def test_advance_version(self):
     blessed_version = BlessedVersion('some_name', 'some_owner')
     self.assertEqual('some_name', blessed_version.name)
     self.assertEqual('some_owner', blessed_version.owner)
     versions = []
     for _ in range(1, 1000):
         versions.append(blessed_version.advance_version())
     sorted_versions = list(versions)
     sorted_versions.sort()
     self.assertEqual(sorted_versions, versions)
Exemplo n.º 4
0
 def test_advance_version(self):
     blessed_version = BlessedVersion('some_name', 'some_owner')
     self.assertEqual('some_name', blessed_version.name)
     self.assertEqual('some_owner', blessed_version.owner)
     versions = []
     for _ in range(1, 1000):
         versions.append(blessed_version.advance_version())
     sorted_versions = list(versions)
     sorted_versions.sort()
     self.assertEqual(sorted_versions, versions)