def test_duplicate_name(self):
        # Create a mock store and put a participant in it
        participant = participant_update.ParticipantObject(
            participantid='0000000000000000', minfo={
                'name': 'participant',
            })
        store = MarketPlaceGlobalStore()
        store[participant.ObjectID] = participant.dump()

        # Because we have not "registered" any holdings, the name
        # should not be a duplicate
        update = holding_update.Register(
            update_type=holding_update.Register.UpdateType,
            creator_id=participant.ObjectID,
            name='/holding')
        self.assertTrue(
            market_place_object_update.global_is_valid_name(
                store,
                name='/holding',
                object_type=update.ObjectType,
                creator_id=participant.ObjectID,
            ))

        # Add a holding to the store with the creator being the participant
        # we inserted initially
        holding = holding_update.HoldingObject(objectid='0000000000000001',
                                               minfo={
                                                   'name':
                                                   '//participant/holding',
                                                   'creator':
                                                   participant.ObjectID
                                               })
        store[holding.ObjectID] = holding.dump()

        # Because the holding name is in the store, trying to register using
        # a relative name based upon creator and a fully-qualified name should
        # not be a valid name as it is a duplicate
        update = holding_update.Register(
            update_type=holding_update.Register.UpdateType,
            creator_id=participant.ObjectID,
            name='/holding')
        self.assertFalse(
            market_place_object_update.global_is_valid_name(
                store,
                name='/holding',
                object_type=update.ObjectType,
                creator_id=participant.ObjectID))
        update = holding_update.Register(
            update_type=holding_update.Register.UpdateType,
            creator_id=participant.ObjectID,
            name='//participant/holding')
        self.assertFalse(
            market_place_object_update.global_is_valid_name(
                store,
                name='//participant/holding',
                object_type=update.ObjectType,
                creator_id=participant.ObjectID))
Esempio n. 2
0
    def test_duplicate_name(self):
        # Create a mock store and put a participant in it
        participant = participant_update.ParticipantObject(
            participantid='0000000000000000',
            minfo={
                'name': 'participant',
            })
        store = MockMarketPlaceGlobalStore()
        store[participant.ObjectID] = participant.dump()
        store.bind(store.i2n(participant.ObjectID), participant.ObjectID)

        # Because we have not "registered" any holdings, the name
        # should not be a duplicate
        update = holding_update.UpdateName(
            minfo={
                'ObjectID': '0000000000000001',
                'CreatorID': participant.ObjectID,
                'Name': '/holding'
            })
        self.assertTrue(update.is_valid_name(store))

        # Add a holding to the store with the creator being the participant
        # we inserted initially
        holding = holding_update.HoldingObject(
            objectid='0000000000000001',
            minfo={
                'name': '//participant/holding',
                'creator': participant.ObjectID
            })
        store[holding.ObjectID] = holding.dump()
        store.bind(store.i2n(holding.ObjectID), holding.ObjectID)

        # Because the holding name is in the store, trying to update the name
        # using a relative name based upon creator and a fully-qualified name
        # should not be a valid name as it is a duplicate
        update = holding_update.UpdateName(
            minfo={
                'ObjectID': holding.ObjectID,
                'CreatorID': participant.ObjectID,
                'Name': '/holding'
            })
        self.assertFalse(update.is_valid_name(store))
        update = holding_update.UpdateName(
            minfo={
                'ObjectID': holding.ObjectID,
                'CreatorID': participant.ObjectID,
                'Name': '//participant/holding'
            })
        self.assertFalse(update.is_valid_name(store))