Ejemplo n.º 1
0
    def test_deserialize_complete(self):
        route = Route.deserialize({
            'id': 'id1',
            'path': '/endpoint_\\w*',
            'method': 'GET',
            'auth': {
                'method': 'basic',
                'username': '******',
                'password': '******'
            },
            'response_selection': 'random',
            'responses': [
                {
                    'id': 'response_1',
                    'body': {
                        'works': True
                    }
                }
            ]
        })

        assert route.id == 'id1'
        assert isinstance(route.path, re.Pattern)
        assert route.method == 'GET'
        assert route.auth.method == 'basic'
        assert route.response_selection == ResponseSelectionStrategy.random
        assert route.is_active == True
Ejemplo n.º 2
0
 def test_deserialize_duplicate_response_ids(self):
     with pytest.raises(RouteConfigurationError):
         route = Route.deserialize({
             'id': 'id1',
             'path': '/endpoint_\\w*',
             'responses': [
                 {
                     'id': 'duplicate',
                     'body': ''
                 },
                 {
                     'id': 'duplicate',
                     'body': ''
                 }
             ]
         })
Ejemplo n.º 3
0
    def test_deserialize_minimal(self):
        route = Route.deserialize({
            'id': 'id1',
            'path': '/endpoint_\\w*',
            'responses': [
                {
                    'body': ''
                }
            ]
        })

        assert route.id == 'id1'
        assert isinstance(route.path, re.Pattern)
        assert route.method == 'GET'
        assert isinstance(route.auth, NoAuth)
        assert route.response_selection == ResponseSelectionStrategy.greedy
        assert route.is_active == True