def check_telescope(file_input=None, is_json=False): """Creates a machine object to process the 10 latest telescope posts""" if is_json: url_machine = url_class.urlAutomationMachine(file_input, is_json) url_machine.processTelescope() else: url_machine = url_class.urlAutomationMachine(file_input) url_machine.processTelescope()
def check_url(file_input, is_json=False): """Creates a machine object to process a single URL""" if is_json: url_machine = url_class.urlAutomationMachine(file_input, is_json) url_machine.processUrl() else: url_machine = url_class.urlAutomationMachine(file_input) url_machine.processUrl()
def check_file(file_input, is_json=False, ignore=None): """Creates a machine object to process a file of URLs""" if is_json: url_machine = url_class.urlAutomationMachine(file_input, is_json, ignore) url_machine.processFile() else: url_machine = url_class.urlAutomationMachine(file_input, False, ignore) url_machine.processFile()
def test_file_upload_is_not_file(): test_url = urlAutomationMachine({}) with pytest.raises(ValueError) as error_value: test_url.processFile() assert "Function requires a file to be inserted" in str(error_value)
def test_file_upload_empty(): test_url = urlAutomationMachine() with pytest.raises(AttributeError) as error_value: test_url.processFile() assert "A parameter is required" in str(error_value)
def test_process_url_failed(example_urls): url = example_urls[1] test_url = urlAutomationMachine(url) test_url.processUrl() assert (test_url.getStatus()) == 404
def test_url_unknown(example_urls): url = example_urls[2] test_url = urlAutomationMachine(url) test_url.processUrl() assert (test_url.getStatus()) == 403
def test_url_is_not_correct(): url = "htt://www.google.ca" test_url = urlAutomationMachine(url) assert (test_url.checkUrl()) == None