Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_default_search(self):
results = CargoMovements().search(filter_activity="loading_state")
print(len(results))
def test_defaullt_search(self):
results = CargoMovements().search()
print(len(results))
def test_search_single_filter_id(self):
df = (
CargoMovements()
.search(
filter_activity="loading_state",
filter_products="6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653",
filter_time_min=datetime(2019, 8, 29),
filter_time_max=datetime(2019, 8, 29, 0, 10),
)
.to_df()
.head(2)
)
assert len(df) == 2
def test_to_df_all_columns(self):
df = (
CargoMovements()
.search(
filter_activity="loading_state",
filter_products="6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653",
filter_time_min=datetime(2019, 8, 29),
filter_time_max=datetime(2019, 8, 29, 0, 10),
)
.to_df(columns="all")
.head(2)
)
assert len(df) == 2
def test_search_to_list(self):
CargoMovements().search(
filter_products=[
"6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653"
],
filter_time_min=datetime(2019, 8, 29),
filter_time_max=datetime(2019, 8, 29, 0, 10),
filter_activity="loading_state",
).to_list()
def test_search_single_filter_origin_name(self):
df = (
CargoMovements()
.search(
filter_activity="loading_state",
filter_origins=[
g.id
for g in Geographies().search(term="rotterdam").to_list()
if "port" in g.layer
],
filter_time_min=datetime(2019, 8, 29),
filter_time_max=datetime(2019, 8, 29, 0, 10),
)
.to_df()
.head(2)
)
assert len(df) == 2
def test_search_single_filter_id(self):
df = CargoMovements().search(
filter_products='6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653',
filter_time_min="2019-08-29T00:00:00.000Z",
filter_time_max="2019-08-29T00:10:00.000Z",
).to_df().head(2)
assert len(df) == 2
def test_search_list_filter_id(self):
df = (
CargoMovements()
.search(
filter_products=[
"6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653"
],
filter_time_min=datetime(2019, 8, 29),
filter_time_max=datetime(2019, 8, 29, 0, 10),
filter_activity="loading_state",
)
.to_df()
.head(2)
)
assert len(df) == 2
print(to_markdown(df))
def test_search_list_filter_id(self):
df = CargoMovements().search(
filter_products=['6f11b0724c9a4e85ffa7f1445bc768f054af755a090118dcf99f14745c261653'],
filter_time_min="2019-08-29T00:00:00.000Z",
filter_time_max="2019-08-29T00:10:00.000Z",
).to_df().head(2)
print(tabulate.tabulate(df))
def test_search_single_filter_owner_name(self):
df = (
CargoMovements()
.search(
filter_activity="loading_state",
filter_owners=[
c.id for c in Corporations().search(term="DHT").to_list()
],
filter_time_min=datetime(2018, 10, 1, 0),
filter_time_max=datetime(2018, 10, 5, 1),
)
.to_df()
.head(2)
)
assert len(df) == 2