Ejemplo n.º 1
0
    def test_serialize_deserialize_complete(self):
        response = RouteResponse.deserialize({
            'id': 'id',
            'status': 400,
            'weight': 0.3,
            'repeat': 3,
            'delay': [0.1, 0.2],
            'headers': {
                'content-type': 'application/json'
            },
            'body': {
                'works': True
            }
        })

        assert response.serialize() == {
            'id': 'id',
            'status': 400,
            'weight': 0.3,
            'repeat': 3,
            'delay': [0.1, 0.2],
            'is_active': True,
            'used_count': 0,
            'headers': {
                'content-type': 'application/json'
            },
            'body': {
                'works': True
            }
        }
Ejemplo n.º 2
0
    def test_deserialize_complete(self):
        response = RouteResponse.deserialize({
            'id': 'id',
            'status': 400,
            'weight': 0.3,
            'repeat': 3,
            'delay': [0.1, 0.2],
            'headers': {
                'content-type': 'application/json'
            },
            'body': {
                'works': True
            }
        })

        assert response.id == 'id'
        assert response.status == 400
        assert response.weight == 0.3
        assert response.repeat == 3
        assert isinstance(response.delay, Delay)
        assert response.delay.min_delay == 0.1
        assert response.delay.max_delay == 0.2
        assert response.headers == {
            'content-type': 'application/json'
        }
        assert response.body == {
            'works': True
        }
Ejemplo n.º 3
0
 def test_deserialize_minimal(self):
     response = RouteResponse.deserialize({
         'id': 'id',
         'body': '',
     })
     assert response.id == 'id'
     assert response.status == 200
     assert response.weight == 0.5
     assert response.repeat == None
     assert isinstance(response.delay, Delay)
     assert response.delay.min_delay == 0.0
     assert response.delay.max_delay == 0.0
     assert response.headers == {}
     assert response.body == ''