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())
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())
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
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
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)
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)