Skip to content

Commit

Permalink
- Move F-R models to services (#443)
Browse files Browse the repository at this point in the history
- Move F-R models tests to services tests
- Re-record F-R cassettes
  • Loading branch information
nwithan8 committed Apr 27, 2023
1 parent 35f18ac commit b384d44
Show file tree
Hide file tree
Showing 159 changed files with 3,598 additions and 5,469 deletions.
25 changes: 0 additions & 25 deletions EasyPost.Tests/BetaFeaturesTests/ModelsTests/InsuranceTest.cs

This file was deleted.

74 changes: 0 additions & 74 deletions EasyPost.Tests/BetaFeaturesTests/ModelsTests/OrderTest.cs

This file was deleted.

56 changes: 0 additions & 56 deletions EasyPost.Tests/BetaFeaturesTests/ModelsTests/PickupTest.cs

This file was deleted.

48 changes: 48 additions & 0 deletions EasyPost.Tests/BetaFeaturesTests/ServicesTests/OrderServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,54 @@ public async Task TestCreate()
Assert.NotNull(order.Rates);
}

[Fact]
[CrudOperations.Update]
[Testing.Function]
public async Task TestBuy()
{
UseVCR("buy");

// buy with a carrier and service
Dictionary<string, object> orderCreateData = Fixtures.BasicOrder;

BetaFeatures.Parameters.Orders.Create orderCreateParameters = Fixtures.Parameters.Orders.Create(orderCreateData);

Order order = await Client.Order.Create(orderCreateParameters);

BetaFeatures.Parameters.Orders.Buy orderBuyParameters = new BetaFeatures.Parameters.Orders.Buy(Fixtures.Usps, Fixtures.UspsService);

order = await Client.Order.Buy(order.Id, orderBuyParameters);

List<Shipment> shipments = order.Shipments;

foreach (Shipment shipment in shipments)
{
Assert.IsType<Shipment>(shipment);
Assert.NotNull(shipment.PostageLabel);
}

// buy with a rate
orderCreateData = Fixtures.BasicOrder;

orderCreateParameters = Fixtures.Parameters.Orders.Create(orderCreateData);

order = await Client.Order.Create(orderCreateParameters);

Rate rate = order.LowestRate();

orderBuyParameters = new BetaFeatures.Parameters.Orders.Buy(rate);

order = await Client.Order.Buy(order.Id, rate);

shipments = order.Shipments;

foreach (Shipment shipment in shipments)
{
Assert.IsType<Shipment>(shipment);
Assert.NotNull(shipment.PostageLabel);
}
}

#endregion

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ public async Task TestAll()
}
}

[Fact]
[CrudOperations.Update]
[Testing.Function]
public async Task TestBuy()
{
UseVCR("buy");

Dictionary<string, object> shipmentData = Fixtures.OneCallBuyShipment;

BetaFeatures.Parameters.Shipments.Create shipmentCreateParameters = Fixtures.Parameters.Shipments.Create(shipmentData);

Shipment shipment = await Client.Shipment.Create(shipmentCreateParameters);

Dictionary<string, object> pickupData = Fixtures.BasicPickup;
pickupData["shipment"] = shipment;

BetaFeatures.Parameters.Pickups.Create pickupCreateParameters = Fixtures.Parameters.Pickups.Create(pickupData);

Pickup pickup = await Client.Pickup.Create(pickupCreateParameters);

BetaFeatures.Parameters.Pickups.Buy pickupBuyParameters = new BetaFeatures.Parameters.Pickups.Buy(Fixtures.Usps, Fixtures.PickupService);

pickup = await Client.Pickup.Buy(pickup.Id, pickupBuyParameters);

Assert.IsType<Pickup>(pickup);
Assert.StartsWith("pickup_", pickup.Id);
Assert.NotNull(pickup.Confirmation);
Assert.Equal("scheduled", pickup.Status);
}

#endregion

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace EasyPost.Tests.BetaFeaturesTests.ServicesTests
{
public class PartnerServiceTests : UnitTest
public class ReferralCustomerServiceTests : UnitTest
{
public PartnerServiceTests() : base("partner_service_with_parameters", TestUtils.ApiKey.Partner)
public ReferralCustomerServiceTests() : base("referral_customer_service_with_parameters", TestUtils.ApiKey.Partner)
{
}

Expand All @@ -30,7 +30,7 @@ public async Task TestCreateReferral()

BetaFeatures.Parameters.ReferralCustomers.CreateReferralCustomer parameters = Fixtures.Parameters.ReferralCustomers.CreateReferralCustomer(data);

ReferralCustomer referralCustomer = await Client.Partner.CreateReferral(parameters);
ReferralCustomer referralCustomer = await Client.ReferralCustomer.CreateReferral(parameters);

Assert.NotNull(referralCustomer);
Assert.IsType<ReferralCustomer>(referralCustomer);
Expand All @@ -49,7 +49,7 @@ public async Task TestAll()

BetaFeatures.Parameters.ReferralCustomers.All parameters = Fixtures.Parameters.ReferralCustomers.All(data);

ReferralCustomerCollection referralCustomerCollection = await Client.Partner.All(parameters);
ReferralCustomerCollection referralCustomerCollection = await Client.ReferralCustomer.All(parameters);
List<ReferralCustomer> referralCustomers = referralCustomerCollection.ReferralCustomers;

Assert.True(referralCustomers.Count <= Fixtures.PageSize);
Expand Down
2 changes: 1 addition & 1 deletion EasyPost.Tests/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static Dictionary<string, object> BasicPickup
{
Dictionary<string, object> fixture = GetFixtureStructure().Pickups.Basic;

const string pickupDate = "2023-03-21";
const string pickupDate = "2023-04-27";

fixture.AddOrUpdate("min_datetime", pickupDate);
fixture.AddOrUpdate("max_datetime", pickupDate);
Expand Down
44 changes: 0 additions & 44 deletions EasyPost.Tests/ModelsTests/InsuranceTest.cs

This file was deleted.

Loading

0 comments on commit b384d44

Please sign in to comment.