Ejemplo n.º 1
0
    def run(self):
        from Naked.toolshed.network import HTTP
        http = HTTP(self.url)  # use the python.org url for the classifier list

        print('•naked• Pulling the classifier list from python.org...')

        res = http.get()  # get the list
        test_list = res.split('\n')  # split on newlines

        if self.needle == "":  # user did not enter a search string, print the entire list
            print(
                "•naked• You did not provide a search string.  Here is the entire list:"
            )
            print(' ')
            for item in test_list:
                print(item)
        else:  # user entered a search string, find it
            lower_needle = self.needle.lower()
            print("•naked• Performing a case insensitive search for '" +
                  self.needle + "'")
            print(' ')
            filtered_list = [
                x for x in test_list if lower_needle in x.lower()
            ]  #case insensitive match for the search string
            for item in filtered_list:
                print(item)

        exit_success()  # exit with zero status code
Ejemplo n.º 2
0
    def post_response(self):
        try:
            the_url = prepare_url(self.url)
            http = HTTP(the_url)
            http.post()
            resp = http.response()

            # confirm that a response was returned, abort if not
            if resp == None and the_url.startswith('https://'):
                stderr("Unable to connect to the requested URL. This can happen if the secure HTTP protocol is not supported at the requested URL.")
                sys.exit(1)
            elif resp == None:
                stderr("Unable to connect to the requested URL. Please confirm your URL and try again.")
                sys.exit(1)

            if len(resp.history) > 0:
                count = len(resp.history)
                for i in range(count):
                    print(str(resp.history[i].status_code) + " : " + str(resp.history[i].url))
            print(str(http.res.status_code) + " : " + the_url)
            exit_success()
        except ConnectionError as ce:
            error_string = "Unable to connect to the URL, " + self.url
            stderr(error_string, 1)
        except Exception as e:
            raise e
Ejemplo n.º 3
0
 def test_http_get_response_check_404(self):
     """Confirm that the response object contains a 404 status code when authentication required"""
     http = HTTP('http://httpbin.org/status/404')
     http.get()
     self.assertEqual(http.res.status_code, 404)
     response = http.response()
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 4
0
 def test_http_get_response_obj_present(self):
     """Confirm that response object is set after GET request with site that exists"""
     http = HTTP('http://google.com')
     http.get()
     self.assertTrue(http.res)  # the response object
     self.assertTrue(http.res.content)  # the content of the response
     self.assertTrue(http.res.status_code)  # the status code
Ejemplo n.º 5
0
 def test_http_get_response_check_200(self):
     """Confirm that the response object contains 200 status code"""
     http = HTTP('http://httpbin.org/status/200')
     http.get()
     self.assertEqual(http.res.status_code, 200) # test the response object attribute
     response = http.response()
     self.assertEqual(response.status_code, 200) # test the returned object from the response() method
    def post_response(self):
        try:
            the_url = prepare_url(self.url)
            http = HTTP(the_url)
            http.post()
            resp = http.response()

            # confirm that a response was returned, abort if not
            if resp == None and the_url.startswith('https://'):
                stderr(
                    "Unable to connect to the requested URL. This can happen if the secure HTTP protocol is not supported at the requested URL."
                )
                sys.exit(1)
            elif resp == None:
                stderr(
                    "Unable to connect to the requested URL. Please confirm your URL and try again."
                )
                sys.exit(1)

            if len(resp.history) > 0:
                count = len(resp.history)
                for i in range(count):
                    print(
                        str(resp.history[i].status_code) + " : " +
                        str(resp.history[i].url))
            print(str(http.res.status_code) + " : " + the_url)
            exit_success()
        except ConnectionError as ce:
            error_string = "Unable to connect to the URL, " + self.url
            stderr(error_string, 1)
        except Exception as e:
            raise e
Ejemplo n.º 7
0
 def test_http_get_response_check_301(self):
     """Confirm that the reponse object contains 301 status code when do not follow redirects"""
     http = HTTP('http://httpbin.org/status/301')
     http.get(False) # do not follow redirects
     self.assertEqual(http.res.status_code, 301)
     response = http.response()
     self.assertEqual(response.status_code, 301)
Ejemplo n.º 8
0
 def test_http_get_status_check_false(self):
     """Confirm the truth check for status response code OK is False for non-existent site"""
     http = HTTP('http://www.abogussitename.com')
     self.assertEqual(http.get_status_ok(), False)
     self.assertEqual(
         http.res, None
     )  # confirm that the response object is None when site does not exist
Ejemplo n.º 9
0
 def test_http_get_text_exists(self):
     """Test HTTP GET request with text file write does not overwrite existing file by default"""
     filepath = os.path.join('testfiles', 'keep', 'file1.txt')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test.")
     http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
     self.assertFalse(http.get_txt_write_file(filepath)) # should not overwrite by default
Ejemplo n.º 10
0
 def test_http_get_response_check_404(self):
     """Confirm that the response object contains a 404 status code when authentication required"""
     http = HTTP('http://httpbin.org/status/404')
     http.get()
     self.assertEqual(http.res.status_code, 404)
     response = http.response()
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 11
0
 def test_http_get_status_check_true(self):
     """Confirm the truth check for status response code OK (=200) is True when should be true"""
     http = HTTP('http://httpbin.org/status/200')
     self.assertEqual(http.get_status_ok(), True)
     self.assertEqual(
         http.res.status_code, 200
     )  #confirm that the response object is set after the get_status_ok() call
Ejemplo n.º 12
0
 def test_http_get_binary_file_exists(self):
     """Test HTTP GET request and write to binary file when it does exist - should not overwrite by default"""
     filepath = os.path.join('testfiles', 'keep', 'test.tar.gz')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test")
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     self.assertFalse(http.get_bin_write_file(filepath)) # should not overwrite file by default
Ejemplo n.º 13
0
 def test_http_get_response_check_301(self):
     """Confirm that the reponse object contains 301 status code when do not follow redirects"""
     http = HTTP('http://httpbin.org/status/301')
     http.get(False)  # do not follow redirects
     self.assertEqual(http.res.status_code, 301)
     response = http.response()
     self.assertEqual(response.status_code, 301)
Ejemplo n.º 14
0
 def test_http_get_response_obj_present(self):
     """Confirm that response object is set after GET request with site that exists"""
     http = HTTP('http://google.com')
     http.get()
     self.assertTrue(http.res)             # the response object
     self.assertTrue(http.res.content)     # the content of the response
     self.assertTrue(http.res.status_code) # the status code
Ejemplo n.º 15
0
 def test_http_post_binary_file_present(self):
     """Test HTTP POST request binary file write when file does exist - should not write by default"""
     filepath = os.path.join('testfiles', 'keep', 'test.tar.gz')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for unit test")
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath)
     self.assertEqual(False, response)
Ejemplo n.º 16
0
 def test_http_post_text_file_present(self):
     """Test HTTP POST request text file write does not occur when file already exists"""
     filepath = os.path.join('testfiles', 'keep', 'file1.txt')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for unit test")
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath)
     self.assertEqual(False, response)
Ejemplo n.º 17
0
    def test_http_get_ssl(self):
        """Test HTTP GET request content data with secure HTTP"""
        http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
        http_text = http.get()

        if state.py2:
            self.http_string = unicode(self.http_string)
        self.assertEqual(http_text.strip(), self.http_string.strip())
Ejemplo n.º 18
0
 def test_http_post_text_file_present(self):
     """Test HTTP POST request text file write does not occur when file already exists"""
     filepath = os.path.join('testfiles', 'keep', 'file1.txt')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for unit test")
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath)
     self.assertEqual(False, response)
Ejemplo n.º 19
0
 def test_http_post_binary_file_present(self):
     """Test HTTP POST request binary file write when file does exist - should not write by default"""
     filepath = os.path.join('testfiles', 'keep', 'test.tar.gz')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for unit test")
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath)
     self.assertEqual(False, response)
Ejemplo n.º 20
0
 def test_http_get_binary_file_absent(self):
     """Test HTTP GET request and write to binary file when it does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'test.tar.gz')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     http.get_bin_write_file(filepath)
     self.assertTrue(file_exists(filepath))
Ejemplo n.º 21
0
 def test_http_get_binary_file_exists(self):
     """Test HTTP GET request and write to binary file when it does exist - should not overwrite by default"""
     filepath = os.path.join('testfiles', 'keep', 'test.tar.gz')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test")
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     self.assertFalse(http.get_bin_write_file(
         filepath))  # should not overwrite file by default
Ejemplo n.º 22
0
 def test_http_get_binary_file_absent(self):
     """Test HTTP GET request and write to binary file when it does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'test.tar.gz')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     http.get_bin_write_file(filepath)
     self.assertTrue(file_exists(filepath))
Ejemplo n.º 23
0
 def test_http_get_text_exists_request_overwrite(self):
     """Test HTTP GET request with text file write does overwrite existing file when requested to do so"""
     filepath = os.path.join('testfiles', 'testdir', 'test.txt')
     http = HTTP('https://raw.github.com/chrissimpkins/six-four/master/LICENSE')
     fw = FileWriter(filepath)
     fw.write("test")
     http.get_txt_write_file(filepath, overwrite_existing=True)
     self.assertEqual(FileReader(filepath).read().strip(), self.http_string.strip())
Ejemplo n.º 24
0
 def test_http_get_text_exists(self):
     """Test HTTP GET request with text file write does not overwrite existing file by default"""
     filepath = os.path.join('testfiles', 'keep', 'file1.txt')
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test.")
     http = HTTP(
         "https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
     self.assertFalse(http.get_txt_write_file(
         filepath))  # should not overwrite by default
Ejemplo n.º 25
0
    def test_http_get_ssl(self):
        """Test HTTP GET request content data with secure HTTP"""
        http = HTTP(
            "https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
        http_text = http.get()

        if state.py2:
            self.http_string = unicode(self.http_string)
        self.assertEqual(http_text.strip(), self.http_string.strip())
Ejemplo n.º 26
0
 def test_http_post_text_file_present_request_overwrite(self):
     """Test HTTP request text file write does occur when file present and request overwrite"""
     filepath = os.path.join('testfiles', 'testdir', 'post.txt')
     if not file_exists(filepath):
         fw = FileWriter(filepath)
         fw.write('test')
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath, overwrite_existing=True)
     self.assertEqual(True, response)
Ejemplo n.º 27
0
 def test_http_get_response_obj_nonexistentsite(self):
     """Test the response object after GET request for a non-existent site"""
     http = HTTP('http://bigtimebogussite.io')
     self.assertEqual(False, http.get())
     self.assertEqual(None, http.res)
     with self.assertRaises(AttributeError):
         http.res.content
     with self.assertRaises(AttributeError):
         http.res.status_code
Ejemplo n.º 28
0
 def test_http_post_text_file_present_request_overwrite(self):
     """Test HTTP request text file write does occur when file present and request overwrite"""
     filepath = os.path.join('testfiles', 'testdir', 'post.txt')
     if not file_exists(filepath):
         fw = FileWriter(filepath)
         fw.write('test')
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath, overwrite_existing=True)
     self.assertEqual(True, response)
Ejemplo n.º 29
0
 def test_http_get_response_obj_nonexistentsite(self):
     """Test the response object after GET request for a non-existent site"""
     http = HTTP('http://bigtimebogussite.io')
     self.assertEqual(False, http.get())
     self.assertEqual(None, http.res)
     with self.assertRaises(AttributeError):
         http.res.content
     with self.assertRaises(AttributeError):
         http.res.status_code
Ejemplo n.º 30
0
    def test_http_get_type(self):
        """Test the HTTP GET request return value type"""
        http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
        http_text = http.get()

        if state.py2:
            self.assertEqual(type(u"test string"), type(http_text))
        else:
            self.assertEqual(type(str("test string")), type(http_text))
Ejemplo n.º 31
0
 def test_http_post_binary_file_absent(self):
     """Test HTTP POST request binary file write when the file does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'post.gz')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("http://httpbin.org/gzip")
     http_data_write = http.post_bin_write_file(filepath)
     self.assertEqual(True, http_data_write) #test boolean for confirmation of data write
     self.assertEqual(True, file_exists(filepath))
Ejemplo n.º 32
0
    def test_http_get_type(self):
        """Test the HTTP GET request return value type"""
        http = HTTP(
            "https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
        http_text = http.get()

        if state.py2:
            self.assertEqual(type(u"test string"), type(http_text))
        else:
            self.assertEqual(type(str("test string")), type(http_text))
Ejemplo n.º 33
0
 def test_http_post_binary_file_present_request_overwrite(self):
     """Test HTTP POST request binary file write when file does exist and request for overwrite"""
     filepath = os.path.join('testfiles', 'testdir', 'post.gz')
     if not file_exists(filepath):
         fw = FileWriter(filepath)
         fw.write('test')
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath, overwrite_existing=True)
     self.assertEqual(True, response)
     self.assertEqual(True, file_exists(filepath))
Ejemplo n.º 34
0
 def test_http_post_binary_file_present_request_overwrite(self):
     """Test HTTP POST request binary file write when file does exist and request for overwrite"""
     filepath = os.path.join('testfiles', 'testdir', 'post.gz')
     if not file_exists(filepath):
         fw = FileWriter(filepath)
         fw.write('test')
     http = HTTP('http://httpbin.org/gzip')
     response = http.post_bin_write_file(filepath, overwrite_existing=True)
     self.assertEqual(True, response)
     self.assertEqual(True, file_exists(filepath))
Ejemplo n.º 35
0
 def test_http_get_binary_file_exists_request_overwrite(self):
     """Test HTTP GET request and write binary file executes the write when the file exists and overwrite requested"""
     filepath = os.path.join('testfiles', 'testdir', 'test.tar.gz')
     fw = FileWriter(filepath)
     fw.write("test")
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test")
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     http.get_bin_write_file(filepath, overwrite_existing=True)
     self.assertTrue(file_exists(filepath))
Ejemplo n.º 36
0
 def test_http_get_text_exists_request_overwrite(self):
     """Test HTTP GET request with text file write does overwrite existing file when requested to do so"""
     filepath = os.path.join('testfiles', 'testdir', 'test.txt')
     http = HTTP(
         'https://raw.github.com/chrissimpkins/six-four/master/LICENSE')
     fw = FileWriter(filepath)
     fw.write("test")
     http.get_txt_write_file(filepath, overwrite_existing=True)
     self.assertEqual(
         FileReader(filepath).read().strip(), self.http_string.strip())
Ejemplo n.º 37
0
 def test_http_get_binary_file_exists_request_overwrite(self):
     """Test HTTP GET request and write binary file executes the write when the file exists and overwrite requested"""
     filepath = os.path.join('testfiles', 'testdir', 'test.tar.gz')
     fw = FileWriter(filepath)
     fw.write("test")
     if not file_exists(filepath):
         raise RuntimeError("Missing test file for the unit test")
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     http.get_bin_write_file(filepath, overwrite_existing=True)
     self.assertTrue(file_exists(filepath))
Ejemplo n.º 38
0
 def test_http_get_response_check_200(self):
     """Confirm that the response object contains 200 status code"""
     http = HTTP('http://httpbin.org/status/200')
     http.get()
     self.assertEqual(http.res.status_code,
                      200)  # test the response object attribute
     response = http.response()
     self.assertEqual(
         response.status_code,
         200)  # test the returned object from the response() method
Ejemplo n.º 39
0
 def test_http_post_binary_file_absent(self):
     """Test HTTP POST request binary file write when the file does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'post.gz')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("http://httpbin.org/gzip")
     http_data_write = http.post_bin_write_file(filepath)
     self.assertEqual(
         True,
         http_data_write)  #test boolean for confirmation of data write
     self.assertEqual(True, file_exists(filepath))
Ejemplo n.º 40
0
 def test_http_get_text_absent(self):
     """Test HTTP get request for text data and write of text file"""
     filepath = os.path.join('testfiles', 'testdir', 'test.txt')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
     response = http.get_txt_write_file(filepath)
     fr = FileReader(filepath)
     the_dl_text = fr.read()
     self.assertEqual(the_dl_text.strip(), self.http_string.strip()) #test that the file write is appropriate
     self.assertEqual(response, True) # test that the response from the method is correct (True on completed file write)
Ejemplo n.º 41
0
def _pull_official_repository_json():
    package = OfficialPackage()
    master_package_json_url = package.get_master_package_description_json_url()
    http = HTTP(master_package_json_url)
    try:
        if http.get_status_ok():
            master_list = http.res.text
            return master_list.strip()   # strip additional spaces, blank end lines off of the list
        else:
            stderr("[!] Unable to pull the remote repository package descriptions (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull the remote repository package descriptions. Error: " + str(e), exit=1)  
Ejemplo n.º 42
0
 def test_http_post_text_file_absent(self):
     """Test HTTP POST request text file write when the file does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'post.txt')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("http://httpbin.org/post")
     http_text = http.post_txt_write_file(filepath)
     fr = FileReader(filepath)
     the_text = fr.read_utf8() #read file in
     textobj = json.loads(the_text) #convert JSON to Py object
     self.assertEqual(True, http_text) # test boolean for confirmation of data write
     self.assertEqual(textobj['url'], 'http://httpbin.org/post') #confirm the write of subset of the text
Ejemplo n.º 43
0
def _pull_official_repository_descriptions():
    package = OfficialPackage()
    master_package_descriptions = package.get_master_package_description_json_url()
    http = HTTP(master_package_descriptions)
    try:
        if http.get_status_ok():
            master_descriptions = http.res.text
            return master_descriptions.strip()
        else:
            stderr("[!] doxx: Unable to pull remote repository descriptions (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull remote repository descriptions Error: " + str(e) + ")", exit=1)
        
Ejemplo n.º 44
0
 def test_http_post_text_file_absent(self):
     """Test HTTP POST request text file write when the file does not exist"""
     filepath = os.path.join('testfiles', 'testdir', 'post.txt')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP("http://httpbin.org/post")
     http_text = http.post_txt_write_file(filepath)
     fr = FileReader(filepath)
     the_text = fr.read_utf8()  #read file in
     textobj = json.loads(the_text)  #convert JSON to Py object
     self.assertEqual(
         True, http_text)  # test boolean for confirmation of data write
     self.assertEqual(textobj['url'], 'http://httpbin.org/post'
                      )  #confirm the write of subset of the text
Ejemplo n.º 45
0
 def test_http_get_text_absent(self):
     """Test HTTP get request for text data and write of text file"""
     filepath = os.path.join('testfiles', 'testdir', 'test.txt')
     if file_exists(filepath):
         os.remove(filepath)
     http = HTTP(
         "https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
     response = http.get_txt_write_file(filepath)
     fr = FileReader(filepath)
     the_dl_text = fr.read()
     self.assertEqual(
         the_dl_text.strip(),
         self.http_string.strip())  #test that the file write is appropriate
     self.assertEqual(
         response, True
     )  # test that the response from the method is correct (True on completed file write)
Ejemplo n.º 46
0
Archivo: pull.py Proyecto: tstyle/doxx
def pull_text_file(url, text_file_name):
    """pulls a remote text file and writes to disk"""
    # pull the binary file data
    http = HTTP(url)
    try:
        if http.get_status_ok():
            text_data = http.res.text
            # write text data to disk
            try:
                fw = FileWriter(text_file_name)
                fw.write(text_data)
            except Exception as e:
                stderr("[!] doxx: File write failed for '" + text_file_name + "'.  Error: " + str(e), exit=1)
        else:
            fail_status_code = http.res.status_code
            stderr("[!] doxx: Unable to pull '" + url + "' (HTTP status code " + str(fail_status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull '" + url + "'. Error: " + str(e), exit=1)
Ejemplo n.º 47
0
def run_pullkey(package_name):
    normalized_package_name = package_name.lower().strip()
    package = OfficialPackage()
    key_file_url = package.get_package_key_url(normalized_package_name)
    try:
        stdout("[*] doxx: Pulling the remote key file...")
        http = HTTP(key_file_url)
        if http.get_status_ok():
            key_file_text = http.res.text
            fr = FileWriter('key.yaml')
            try:
                fr.write(key_file_text)
            except Exception as e:
                stderr("[!] doxx: Unable to write the 'key.yaml' file to disk. Error: " + str(e), exit=1)
            stdout("[*] doxx: Key file pull complete")
        elif http.res.status_code == 404:
            stderr("[!] doxx: Unable to pull the key file because the requested package could not be found. (HTTP status code: 404)", exit=1)
        else:
            stderr("[!] doxx: Unable to pull the key file.  (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull the key file. Error: " + str(e), exit=1)
        
Ejemplo n.º 48
0
    def run(self):
        from Naked.toolshed.network import HTTP
        http = HTTP(self.url) # use the python.org url for the classifier list

        print('•naked• Pulling the classifier list from python.org...')

        res = http.get() # get the list
        test_list = res.split('\n') # split on newlines

        if self.needle == "": # user did not enter a search string, print the entire list
            print("•naked• You did not provide a search string.  Here is the entire list:")
            print(' ')
            for item in test_list:
                print(item)
        else: # user entered a search string, find it
            lower_needle = self.needle.lower()
            print("•naked• Performing a case insensitive search for '" + self.needle + "'")
            print(' ')
            filtered_list = [ x for x in test_list if lower_needle in x.lower() ] #case insensitive match for the search string
            for item in filtered_list:
                print(item)

        exit_success() # exit with zero status code
Ejemplo n.º 49
0
 def test_http_post_status_check_false(self):
     """Test that the status check returns False for POST requst when the site does not exist"""
     http = HTTP('http://www.atrulybogussite.com')
     result = http.post_status_ok()
     self.assertEqual(False, result)
Ejemplo n.º 50
0
 def test_http_post_status_check_true(self):
     """Test that the status check returns True for POST request when it should return True"""
     http = HTTP('http://httpbin.org/post')
     result = http.post_status_ok()
     self.assertEqual(True, result)
Ejemplo n.º 51
0
 def test_http_get_bin_type(self):
     """Test the return value type with the get_bin() method"""
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     bin_data = http.get_bin()
     self.assertEqual(type(b"110"), type(bin_data))
Ejemplo n.º 52
0
 def test_http_get_response_method_return_value_missingsite(self):
     """Test the return type from response() method when non-existent site is requested"""
     http = HTTP('http://www.abogussitename.com')
     http.post()
     self.assertEqual(None, http.response())
Ejemplo n.º 53
0
 def test_http_post_status_check_true(self):
     """Test that the status check returns True for POST request when it should return True"""
     http = HTTP('http://httpbin.org/post')
     result = http.post_status_ok()
     self.assertEqual(True, result)
Ejemplo n.º 54
0
 def test_http_post_response_status_200_ssl(self):
     """Test that the status code 200 is appropriately detected after a SSL POST request"""
     http = HTTP("https://httpbin.org/post")
     http.post()
     self.assertEqual(http.res.status_code, 200)
Ejemplo n.º 55
0
 def test_http_response_none_attribute_error(self):
     """Test that the HTTP response object is None before HTTP method run and attempt to access attribute raises exception"""
     http = HTTP('http://google.com')
     with self.assertRaises(AttributeError):
         http.res.content
Ejemplo n.º 56
0
 def test_http_post_response_status_200_ssl(self):
     """Test that the status code 200 is appropriately detected after a SSL POST request"""
     http = HTTP("https://httpbin.org/post")
     http.post()
     self.assertEqual(http.res.status_code, 200)
Ejemplo n.º 57
0
 def test_http_constructor_with_change_timeout(self):
     """Test HTTP class constructor with change in default timeout duration"""
     http = HTTP("http://www.google.com", 20)
Ejemplo n.º 58
0
 def test_http_post_status_check_false(self):
     """Test that the status check returns False for POST requst when the site does not exist"""
     http = HTTP('http://www.atrulybogussite.com')
     result = http.post_status_ok()
     self.assertEqual(False, result)
Ejemplo n.º 59
0
 def test_http_response_none(self):
     """Test that the HTTP response is None before the run of a HTTP method"""
     http = HTTP('http://google.com')
     self.assertEqual(None, http.res)
Ejemplo n.º 60
0
 def test_http_get_bin_type(self):
     """Test the return value type with the get_bin() method"""
     http = HTTP("https://github.com/chrissimpkins/six-four/tarball/master")
     bin_data = http.get_bin()
     self.assertEqual(type(b"110"), type(bin_data))