Пример #1
0
def test_structure_inject():
    expected_imposter = Imposter(
        Stub(responses=InjectionResponse(inject="function (request) {\n}")),
        port=4546)
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.port == expected_imposter.port
Пример #2
0
def test_imposter_complex_predicates(predicate):
    # Given
    expected = Imposter(Stub(predicate().build()))
    structure = expected.as_structure()

    # When
    actual = Imposter.from_structure(structure)

    # Then
    assert_that(actual, instance_of(Imposter))
    assert_that(
        actual,
        has_identical_properties_to(expected, ignoring=["configuration_url"]))
Пример #3
0
def test_structure_no_record_requests():
    expected_imposter = Imposter(Stub())
    imposter_structure = expected_imposter.as_structure()
    del imposter_structure["recordRequests"]
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.record_requests == expected_imposter.record_requests
Пример #4
0
def test_structure_record_requests():
    expected_imposter = Imposter(Stub(), record_requests=False)
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.record_requests == expected_imposter.record_requests
Пример #5
0
def test_structure_name():
    expected_imposter = Imposter(Stub(), name="darwin")
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.name == expected_imposter.name
Пример #6
0
def test_structure_no_protocol():
    expected_imposter = Imposter(Stub())
    imposter_structure = expected_imposter.as_structure()
    del imposter_structure["protocol"]
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.protocol == expected_imposter.protocol
Пример #7
0
def test_structure_protocol():
    expected_imposter = Imposter(Stub(), protocol="http")
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.protocol == expected_imposter.protocol
Пример #8
0
def test_structure_proxy_port():
    expected_imposter = Imposter(Stub(responses=Proxy("http://darwin.dog")),
                                 port=4546)
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.port == expected_imposter.port
Пример #9
0
def test_structure_response_port():
    expected_imposter = Imposter(Stub(responses=Response()), port=4546)
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.port == expected_imposter.port
Пример #10
0
def test_structure_no_port():
    expected_imposter = Imposter(Stub())
    imposter_structure = expected_imposter.as_structure()
    imposter = Imposter.from_structure(imposter_structure)
    assert imposter.port == expected_imposter.port