| 1 |
#!/usr/bin/env python3 |
| 2 |
from sys import exit |
| 3 |
from test.http_test import HTTPTest |
| 4 |
from misc.wget_file import WgetFile |
| 5 |
|
| 6 |
""" |
| 7 |
Simple test for HTTP POST Requests usiong the --method command |
| 8 |
""" |
| 9 |
############# File Definitions ############################################### |
| 10 |
File1 = """A reader lives a thousand lives before he dies, said Jojen. |
| 11 |
The man who never reads lives only one""" |
| 12 |
|
| 13 |
File1_response = """A reader lives a thousand lives before he dies, said Jojen. |
| 14 |
The man who never reads lives only one |
| 15 |
TestMessage""" |
| 16 |
|
| 17 |
A_File = WgetFile ("File1", File1) |
| 18 |
|
| 19 |
WGET_OPTIONS = "--method=post --body-data=TestMessage" |
| 20 |
WGET_URLS = [["File1"]] |
| 21 |
|
| 22 |
Files = [[A_File]] |
| 23 |
|
| 24 |
ExpectedReturnCode = 0 |
| 25 |
ExpectedDownloadedFiles = [WgetFile ("File1", File1_response)] |
| 26 |
|
| 27 |
################ Pre and Post Test Hooks ##################################### |
| 28 |
pre_test = { |
| 29 |
"ServerFiles" : Files |
| 30 |
} |
| 31 |
test_options = { |
| 32 |
"WgetCommands" : WGET_OPTIONS, |
| 33 |
"Urls" : WGET_URLS |
| 34 |
} |
| 35 |
post_test = { |
| 36 |
"ExpectedFiles" : ExpectedDownloadedFiles, |
| 37 |
"ExpectedRetcode" : ExpectedReturnCode |
| 38 |
} |
| 39 |
|
| 40 |
err = HTTPTest ( |
| 41 |
pre_hook=pre_test, |
| 42 |
test_params=test_options, |
| 43 |
post_hook=post_test |
| 44 |
).begin () |
| 45 |
|
| 46 |
exit (err) |