Beispiel #1
0
def test_create_berth_switch_offer_missing_application_switch(
        api_client, berth_application, berth):
    berth_lease = BerthLeaseFactory(start_date=calculate_season_start_date(),
                                    end_date=calculate_season_end_date())
    berth_application.customer = berth_lease.customer
    berth_application.berth_switch = None
    berth_application.save()

    berth_lease.status = LeaseStatus.PAID
    berth_lease.save()

    variables = {
        "applicationId": to_global_id(BerthApplicationNode,
                                      berth_application.id),
        "newBerthId": to_global_id(BerthNode, berth.id),
    }
    executed = api_client.execute(CREATE_BERTH_SWITCH_OFFER_MUTATION,
                                  input=variables)
    assert_in_errors("Application must be a switch application", executed)
Beispiel #2
0
def test_create_berth_switch_offer(api_client, berth_application, berth):
    berth_lease = BerthLeaseFactory(
        start_date=calculate_season_start_date(),
        end_date=calculate_season_end_date(),
        status=LeaseStatus.PAID,
    )
    berth_application.customer = berth_lease.customer
    berth_application.berth_switch = BerthSwitchFactory(
        berth=berth_lease.berth)
    berth_application.save()
    berth_lease.save()

    variables = {
        "applicationId": to_global_id(BerthApplicationNode,
                                      berth_application.id),
        "newBerthId": to_global_id(BerthNode, berth.id),
    }
    executed = api_client.execute(CREATE_BERTH_SWITCH_OFFER_MUTATION,
                                  input=variables)

    assert executed["data"]["createBerthSwitchOffer"]["berthSwitchOffer"] == {
        "status": OfferStatus.DRAFTED.name,
        "dueDate": None,
        "application": {
            "id": variables["applicationId"],
            "status": "OFFER_GENERATED"
        },
        "customer": {
            "id": to_global_id(ProfileNode, berth_lease.customer.id)
        },
        "lease": {
            "id": to_global_id(BerthLeaseNode, berth_lease.id)
        },
        "berth": {
            "id": variables["newBerthId"]
        },
    }