Пример #1
0
    def test_division(self):
        ''' test that the algorithm divides correctly '''
        vals = {'red': 10, 'blue': 20, 'green': 30}
        keys = vals.keys()
        cake = CollectionResource(keys)
        users = []
        users.append(
            CollectionPreference('mark', {
                'red': 10,
                'blue': 20,
                'green': 30
            }))
        users.append(
            CollectionPreference('john', {
                'red': 10,
                'blue': 30,
                'green': 20
            }))
        users.append(
            CollectionPreference('anna', {
                'red': 30,
                'blue': 20,
                'green': 10
            }))

        algorithm = SealedBidsAuction(users, cake)
        divisions = algorithm.divide()
        for user, pieces in divisions.items():
            self.assertEqual(30, get_total_value(user, pieces))
Пример #2
0
    def test_initializes(self):
        ''' test that the algorithm initializes correctly '''
        keys = ['red', 'blue', 'green', 'yello', 'orange']
        vals = dict((k, 100 / len(keys)) for k in keys)
        cake = CollectionResource(keys)
        users = []
        users.append(CollectionPreference('mark', vals))
        users.append(CollectionPreference('john', vals))

        algorithm = SealedBidsAuction(users, cake)
        self.assertEqual(True, algorithm.is_valid())
Пример #3
0
    def test_initializes(self):
        ''' test that the algorithm initializes correctly '''
        keys = ['red', 'blue', 'green', 'yello', 'orange']
        vals = dict((k, 100/len(keys)) for k in keys)
        cake = CollectionResource(keys)
        users = []
        users.append(CollectionPreference('mark', vals))
        users.append(CollectionPreference('john', vals))

        algorithm = SealedBidsAuction(users, cake)
        self.assertEqual(True, algorithm.is_valid())
Пример #4
0
    def test_division(self):
        ''' test that the algorithm divides correctly '''
        vals = {'red':10, 'blue':20, 'green':30}
        keys = vals.keys()
        cake = CollectionResource(keys)
        users = []
        users.append(CollectionPreference('mark', {'red':10, 'blue':20, 'green':30}))
        users.append(CollectionPreference('john', {'red':10, 'blue':30, 'green':20}))
        users.append(CollectionPreference('anna', {'red':30, 'blue':20, 'green':10}))

        algorithm = SealedBidsAuction(users, cake)
        divisions = algorithm.divide()
        for user, pieces in divisions.items():
            self.assertEqual(30, get_total_value(user, pieces))