Fix #61 price_type NEGOTIABLE without price not supported

This commit is contained in:
sebthom
2022-04-25 13:46:03 +02:00
parent f1e8f53bb1
commit 64ba3d38b4

View File

@@ -241,7 +241,9 @@ class KleinanzeigenBot(SeleniumMixin):
assert_min_len("title", 10) assert_min_len("title", 10)
assert_has_value("description") assert_has_value("description")
assert_one_of("price_type", {"FIXED", "NEGOTIABLE", "GIVE_AWAY", "NOT_APPLICABLE"}) assert_one_of("price_type", {"FIXED", "NEGOTIABLE", "GIVE_AWAY", "NOT_APPLICABLE"})
if not ad_cfg["price_type"] in {"GIVE_AWAY", "NOT_APPLICABLE"}: if ad_cfg["price_type"] == "GIVE_AWAY":
ensure(not safe_get(ad_cfg, "price"), f"-> [price] must not be specified for GIVE_AWAY ad @ [{ad_file}]")
elif ad_cfg["price_type"] == "FIXED":
assert_has_value("price") assert_has_value("price")
assert_one_of("shipping_type", {"PICKUP", "SHIPPING", "NOT_APPLICABLE"}) assert_one_of("shipping_type", {"PICKUP", "SHIPPING", "NOT_APPLICABLE"})
assert_has_value("contact.name") assert_has_value("contact.name")
@@ -419,7 +421,7 @@ class KleinanzeigenBot(SeleniumMixin):
price_type = ad_cfg["price_type"] price_type = ad_cfg["price_type"]
if price_type != "NOT_APPLICABLE": if price_type != "NOT_APPLICABLE":
self.web_select(By.XPATH, "//select[@id='priceType']", price_type) self.web_select(By.XPATH, "//select[@id='priceType']", price_type)
if price_type != "GIVE_AWAY": if safe_get(ad_cfg, "price"):
self.web_input(By.ID, "pstad-price", ad_cfg["price"]) self.web_input(By.ID, "pstad-price", ad_cfg["price"])
############################# #############################