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