-
Notifications
You must be signed in to change notification settings - Fork 12
Add AFP endpoints to SDK #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jack-Burge55
wants to merge
4
commits into
master
Choose a base branch
from
rnd-21261
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /* Fix long module names overflowing */ | ||
| h1, h2, h3, h4, h5, h6 { | ||
| word-wrap: break-word; | ||
| overflow-wrap: break-word; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
tests/endpoints/test_anywhere_freight_pricing_get_price_details.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| from datetime import datetime | ||
|
|
||
| from tests.testcases import TestCaseUsingRealAPI | ||
| from vortexasdk import AnywhereFreightPricingGetPriceDetails | ||
|
|
||
|
|
||
| class TestAnywhereFreightPricingGetPriceDetails(TestCaseUsingRealAPI): | ||
| def test_search_returns_data(self): | ||
| result = AnywhereFreightPricingGetPriceDetails().search( | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| origin_port="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| destination_port="68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| vessel_class="oil_aframax_lr2", | ||
| product="crude", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 | ||
| assert "origin_port" in result_list[0] | ||
| assert "destination_port" in result_list[0] | ||
| assert "vessel_class" in result_list[0] | ||
| assert "rates" in result_list[0] | ||
|
|
||
| def test_search_to_df(self): | ||
| result = AnywhereFreightPricingGetPriceDetails().search( | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| origin_port="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| destination_port="68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| vessel_class="oil_aframax_lr2", | ||
| product="crude", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| df = result.to_df() | ||
| assert len(df) > 0 | ||
| # pd.json_normalize uses dot notation for nested keys | ||
| assert "origin_port.id" in df.columns | ||
| assert "destination_port.id" in df.columns | ||
| assert "vessel_class" in df.columns | ||
|
|
||
| def test_search_with_avoid_zone(self): | ||
| result = AnywhereFreightPricingGetPriceDetails().search( | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| origin_port="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| destination_port="68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| vessel_class="oil_aframax_lr2", | ||
| product="crude", | ||
| unit="usd_per_tonne", | ||
| avoid_zone=["Suez Canal"], | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 |
8 changes: 8 additions & 0 deletions
8
tests/endpoints/test_anywhere_freight_pricing_latest_update_timestamp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from tests.testcases import TestCaseUsingRealAPI | ||
| from vortexasdk import AnywhereFreightPricingLatestUpdateTimestamp | ||
|
|
||
|
Jack-Burge55 marked this conversation as resolved.
|
||
|
|
||
| class TestAnywhereFreightPricingLatestUpdateTimestamp(TestCaseUsingRealAPI): | ||
| def test_search_returns_timestamp(self): | ||
| result = AnywhereFreightPricingLatestUpdateTimestamp().search() | ||
| assert "timestamp" in result | ||
101 changes: 101 additions & 0 deletions
101
tests/endpoints/test_anywhere_freight_pricing_post_price_details.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| from datetime import datetime | ||
|
|
||
| from tests.testcases import TestCaseUsingRealAPI | ||
| from vortexasdk import AnywhereFreightPricingPostPriceDetails | ||
|
|
||
|
|
||
| class TestAnywhereFreightPricingPostPriceDetails(TestCaseUsingRealAPI): | ||
| def test_search_returns_data(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| "destination_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "product": "crude", | ||
| "vessel_class": "oil_aframax_lr2", | ||
| } | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPostPriceDetails().search( | ||
| routes=routes, | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 | ||
| assert "origin_port" in result_list[0] | ||
| assert "destination_port" in result_list[0] | ||
| assert "vessel_class" in result_list[0] | ||
| assert "rates" in result_list[0] | ||
|
|
||
| def test_search_to_df(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| "destination_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "product": "crude", | ||
| "vessel_class": "oil_aframax_lr2", | ||
| } | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPostPriceDetails().search( | ||
| routes=routes, | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| df = result.to_df() | ||
| assert len(df) > 0 | ||
| # pd.json_normalize uses dot notation for nested keys | ||
| assert "origin_port.id" in df.columns | ||
| assert "destination_port.id" in df.columns | ||
| assert "vessel_class" in df.columns | ||
|
|
||
| def test_search_multiple_routes(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| "destination_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "product": "crude", | ||
| "vessel_class": "oil_aframax_lr2", | ||
| }, | ||
| { | ||
| "origin_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "destination_port": "ea4921c8ad4fddb5fe3e7a4f834c1aa5863e43283c73da5f02d93bbc5dba72eb", | ||
| "product": "clean", | ||
| "vessel_class": "oil_handymax_mr2", | ||
| }, | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPostPriceDetails().search( | ||
| routes=routes, | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) >= 2 | ||
|
|
||
| def test_search_with_avoid_zone(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| "destination_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "product": "crude", | ||
| "vessel_class": "oil_aframax_lr2", | ||
| "avoid_zone": ["Suez Canal"], | ||
| } | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPostPriceDetails().search( | ||
| routes=routes, | ||
| time_min=datetime(2024, 1, 1), | ||
| time_max=datetime(2024, 1, 31), | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 |
55 changes: 55 additions & 0 deletions
55
tests/endpoints/test_anywhere_freight_pricing_price_timeseries.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| from datetime import datetime | ||
|
|
||
| from tests.testcases import TestCaseUsingRealAPI | ||
| from vortexasdk import AnywhereFreightPricingPriceTimeseries | ||
|
|
||
|
|
||
| class TestAnywhereFreightPricingPriceTimeseries(TestCaseUsingRealAPI): | ||
| def test_search_returns_data(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "destination_port": "ea4921c8ad4fddb5fe3e7a4f834c1aa5863e43283c73da5f02d93bbc5dba72eb", | ||
| "product": "clean", | ||
| "vessel_class": "oil_handymax_mr2", | ||
| } | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPriceTimeseries().search( | ||
| routes=routes, | ||
| time_min=datetime(2026, 2, 20), | ||
| time_max=datetime(2026, 5, 20), | ||
| frequency="month", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 | ||
| assert "origin_port" in result_list[0] | ||
| assert "destination_port" in result_list[0] | ||
| assert "prices" in result_list[0] | ||
|
|
||
| def test_search_to_df(self): | ||
| routes = [ | ||
| { | ||
| "origin_port": "68faf65af1345067f11dc6723b8da32f00e304a6f33c000118fccd81947deb4e", | ||
| "destination_port": "ea4921c8ad4fddb5fe3e7a4f834c1aa5863e43283c73da5f02d93bbc5dba72eb", | ||
| "product": "clean", | ||
| "vessel_class": "oil_handymax_mr2", | ||
| } | ||
| ] | ||
|
|
||
| result = AnywhereFreightPricingPriceTimeseries().search( | ||
| routes=routes, | ||
| time_min=datetime(2026, 2, 20), | ||
| time_max=datetime(2026, 5, 20), | ||
| frequency="month", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| df = result.to_df() | ||
| assert len(df) > 0 | ||
| # Top-level keys preserved, nested arrays like prices stay as lists | ||
| assert "origin_port" in df.columns | ||
| assert "destination_port" in df.columns | ||
| assert "vessel_class" in df.columns |
45 changes: 45 additions & 0 deletions
45
tests/endpoints/test_anywhere_freight_pricing_top_ports_destination.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from tests.testcases import TestCaseUsingRealAPI | ||
| from vortexasdk import AnywhereFreightPricingTopPortsDestination | ||
|
|
||
|
|
||
| class TestAnywhereFreightPricingTopPortsDestination(TestCaseUsingRealAPI): | ||
| def test_search_returns_data(self): | ||
| result = AnywhereFreightPricingTopPortsDestination().search( | ||
| origin_id="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| vessel_class="oil_handymax_mr2", | ||
| product="clean", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 | ||
| assert "geography" in result_list[0] | ||
| assert "price_details" in result_list[0] | ||
| assert "id" in result_list[0]["geography"] | ||
| assert "name" in result_list[0]["geography"] | ||
|
|
||
| def test_search_to_df(self): | ||
| result = AnywhereFreightPricingTopPortsDestination().search( | ||
| origin_id="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| vessel_class="oil_handymax_mr2", | ||
| product="clean", | ||
| unit="usd_per_tonne", | ||
| ) | ||
|
|
||
| df = result.to_df() | ||
| assert len(df) > 0 | ||
| # pd.json_normalize uses dot notation for nested keys | ||
| assert "geography.id" in df.columns | ||
| assert "geography.name" in df.columns | ||
|
|
||
| def test_search_with_avoid_zone(self): | ||
| result = AnywhereFreightPricingTopPortsDestination().search( | ||
| origin_id="7f314ba0a498c36359b1c88781e94a73e19dcc9bbb030ec6b82f944a73d4da2f", | ||
| vessel_class="oil_handymax_mr2", | ||
| product="clean", | ||
| unit="usd_per_tonne", | ||
| avoid_zone=["Suez Canal"], | ||
| ) | ||
|
|
||
| result_list = result.to_list() | ||
| assert len(result_list) > 0 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.