Beispiel #1
0
def set_bootstrap_response(data):
    Config.base_url = 'http://wiremock:8080/__admin'

    if data is None:
        mapping = Mapping(
            priority=100,
            request=MappingRequest(method=HttpMethods.GET,
                                   url='/api/bootstrap/'),
            response=MappingResponse(status=403, ),
            persistent=False,
        )
    else:
        mapping = Mapping(
            priority=100,
            request=MappingRequest(method=HttpMethods.GET,
                                   url='/api/bootstrap/'),
            response=MappingResponse(
                status=200,
                body=json.dumps(data),
                headers={'Content-Type': 'application/json'}),
            persistent=False,
        )
    Mappings.create_mapping(mapping=mapping)
Beispiel #2
0
    def test_create_mapping(self):
        e = MappingResponse(body="test", status=200)
        resp = e.get_json_data()
        responses.add(responses.POST,
                      "http://localhost/__admin/mappings",
                      json=resp,
                      status=200)

        m = Mapping(priority=1,
                    request=MappingRequest(url="test", method="GET"),
                    response=MappingResponse(status=200, body="test"))

        r = Mappings.create_mapping(m)
        self.assertIsInstance(r, MappingResponse)
        self.assertEqual(200, r.status)
        self.assertEqual("test", r.body)
    def test_create_mapping(self):
        e = MappingResponse(
            body='test',
            status=200
        )
        resp = e.get_json_data()
        responses.add(responses.POST, 'http://localhost/__admin/mappings', json=resp, status=200)

        m = Mapping(
            priority=1,
            request=MappingRequest(url='test', method='GET'),
            response=MappingResponse(status=200, body='test')
        )

        r = Mappings.create_mapping(m)
        self.assertIsInstance(r, MappingResponse)
        self.assertEquals(200, r.status)
        self.assertEquals('test', r.body)