Exemplo n.º 1
0
    def test_update_route_and_change_its_id(self):
        router = Router()
        router.add_route({
            'id': 'id1',
            'path': '/endpoint\\w*',
            'responses': [
                {
                    'id': 'response_1',
                    'body': {
                        'works': True
                    }
                }
            ]
        })

        router.update_route({
            'id': 'id2',
            'path': '/endpoint\\w*',
            'responses': [
                {
                    'id': 'response_1',
                    'body': {
                        'works': True
                    }
                }
            ]
        }, 'id1')
Exemplo n.º 2
0
    def test_update_route_not_present(self):
        router = Router()

        with pytest.raises(MissingRouteError):
            router.update_route({
                'id': 'id1',
                'path': '/endpoint\\w*',
                'responses': [
                    {
                        'id': 'response_1',
                        'body': {
                            'works': True
                        }
                    }
                ]
            }, 'id1')
Exemplo n.º 3
0
    def test_update_route_to_that_already_exists(self):
        router = Router()
        router.add_route({
            'id': 'id1',
            'path': '/endpoint\\w*',
            'responses': [
                {
                    'id': 'response_1',
                    'body': {
                        'works': True
                    }
                }
            ]
        })

        router.add_route({
            'id': 'id2',
            'path': '/endpoint\\w*',
            'responses': [
                {
                    'id': 'response_2',
                    'body': {
                        'works': True
                    }
                }
            ]
        })

        with pytest.raises(DuplicateRouteError):
            router.update_route({
                'id': 'id1',
                'path': '/endpoint\\w*',
                'responses': [
                    {
                        'id': 'response_1',
                        'body': {
                            'works': True
                        }
                    }
                ]
            }, 'id2')