예제 #1
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)
예제 #2
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)
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
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))
예제 #7
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))
예제 #8
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)
예제 #9
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))
예제 #10
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))