def test_upload_keys_default_domain() -> None: from sxcu import SXCU t = SXCU() con = t.upload_image(file=img_loc) expected_keys = ["url", "del_url", "thumb"] assert (list(con.keys()).sort() == expected_keys.sort() ) # sorting because keys are arraged different
def test_delete_image() -> None: from sxcu import SXCU time.sleep(60) # to prevent overloading server t = SXCU() con = t.upload_image(file=img_loc, noembed=True) a = SXCU.delete_image(con["del_url"]) assert a is True
def test_upload_image_default_domain() -> None: import requests from sxcu import SXCU t = SXCU() con = t.upload_image(file=img_loc, noembed=True) con = requests.get(con["url"]) assert open(img_loc, "rb") == con.content
def test_upload_image_to_collection() -> None: time.sleep(60) from sxcu import SXCU t = SXCU() con = t.upload_image( file=img_loc, collection=collection_details["collection_id"], collection_token=collection_details["collection_token"], noembed=True, ) assert con["url"].startswith("https://sxcu.net")
def test_sxcu_file_parser() -> None: from sxcu import SXCU sxcu_file = os.path.join(pathFile, "assets", "sxcu.net - python.is-ne.at.sxcu") time.sleep(60) t = SXCU(file_sxcu=sxcu_file) con = t.upload_image(file=img_loc, noembed=True) # test domain assert con["url"].startswith("https://python.is-ne.at") # test keys expected_keys = ["url", "del_url", "thumb"] assert list(con.keys()).sort() == expected_keys.sort()
def test_ogproperties() -> None: from sxcu import SXCU, og_properties og = og_properties(color="#000", title="Some title", description="A cool description!") con = json.dumps({ "color": "#000", "title": "Some title", "description": "A cool description!", }) assert con == og.export() t = SXCU() a = t.upload_image(file=img_loc, og_properties=og) assert a is not None
def test_image_info() -> None: from sxcu import SXCU # upload image first t = SXCU() time.sleep(60) con = t.upload_image(file=img_loc, noembed=True) details = SXCU.image_details(image_url=con["url"]) assert con["url"] == details["url"] # Now try using id time.sleep(60) id_url = con["url"].split("/")[-1].split(".")[0] details_id = SXCU.image_details(image_id=id_url) assert details_id["url"] == con["url"] try: SXCU.image_details() assert False except AttributeError: assert True