示例#1
0
    def test_add_get_remove(self):
        collection = RelocateCollection()
        relocate = Relocate(self.factory)

        assert_that(calling(collection.get).with_args(relocate.uuid),
                    raises(KeyError).matching(has_callable('__str__', "'{}'".format(relocate.uuid))))
        collection.add(relocate)
        assert_that(collection.get(relocate.uuid),
                    is_(relocate))
        collection.remove(relocate)
        assert_that(calling(collection.get).with_args(relocate.uuid),
                    raises(KeyError).matching(has_callable('__str__', "'{}'".format(relocate.uuid))))
示例#2
0
    def test_given_another_relocate_when_get_by_channel_then_error(self):
        collection = RelocateCollection()
        relocate = Relocate(self.factory)
        collection.add(relocate)

        assert_that(calling(collection.get_by_channel).with_args('unknown'),
                    raises(KeyError).matching(has_callable('__str__', "'unknown'")))
示例#3
0
    def test_given_relocate_when_relocate_ends_then_relocate_removed(self):
        collection = RelocateCollection()
        relocate = Relocate(self.factory)

        collection.add(relocate)
        assert_that(collection.get(relocate.uuid),
                    is_(relocate))

        relocate.events.publish('ended', relocate)
        assert_that(calling(collection.get).with_args(relocate.uuid),
                    raises(KeyError).matching(has_callable('__str__', "'{}'".format(relocate.uuid))))
示例#4
0
    def test_role(self):
        relocate = Relocate(self.factory)
        relocate.relocated_channel = 'relocated'
        relocate.initiator_channel = 'initiator'
        relocate.recipient_channel = 'recipient'

        assert_that(relocate.role('relocated'), equal_to(RelocateRole.relocated))
        assert_that(relocate.role('initiator'), equal_to(RelocateRole.initiator))
        assert_that(relocate.role('recipient'), equal_to(RelocateRole.recipient))
        assert_that(calling(relocate.role).with_args('unknown'),
                    raises(KeyError).matching(has_callable('__str__', equal_to("'unknown'"))))
示例#5
0
    def test_given_no_relocates_when_get_by_channel_then_error(self):
        collection = RelocateCollection()

        assert_that(
            calling(collection.get_by_channel).with_args('unknown'),
            raises(KeyError).matching(has_callable('__str__', "'unknown'")))