Exemplo n.º 1
0
    def test_adjust(self):
        """Test identity group count adjustement."""
        ident_group = scheduler.IdentityGroup(5)
        ident_group.available = set([1, 3])

        ident_group.adjust(7)
        self.assertEqual(set([1, 3, 5, 6]), ident_group.available)

        ident_group.adjust(3)
        self.assertEqual(set([1]), ident_group.available)
Exemplo n.º 2
0
    def test_basic(self):
        """Test basic acquire/release ops."""
        ident_group = scheduler.IdentityGroup(3)
        self.assertEqual(0, ident_group.acquire())
        self.assertEqual(1, ident_group.acquire())
        self.assertEqual(2, ident_group.acquire())
        self.assertEqual(None, ident_group.acquire())

        ident_group.release(1)
        self.assertEqual(1, ident_group.acquire())