| OLD | NEW | 
|   1 # This file is part of the Adblock Plus web scripts, |   1 # This file is part of the Adblock Plus web scripts, | 
|   2 # Copyright (C) 2006-present eyeo GmbH |   2 # Copyright (C) 2006-present eyeo GmbH | 
|   3 # |   3 # | 
|   4 # Adblock Plus is free software: you can redistribute it and/or modify |   4 # Adblock Plus is free software: you can redistribute it and/or modify | 
|   5 # it under the terms of the GNU General Public License version 3 as |   5 # it under the terms of the GNU General Public License version 3 as | 
|   6 # published by the Free Software Foundation. |   6 # published by the Free Software Foundation. | 
|   7 # |   7 # | 
|   8 # Adblock Plus is distributed in the hope that it will be useful, |   8 # Adblock Plus is distributed in the hope that it will be useful, | 
|   9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |   9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  24  |  24  | 
|  25  |  25  | 
|  26 # We make this a fixture instead of a constant so we can modify it in each |  26 # We make this a fixture instead of a constant so we can modify it in each | 
|  27 # test as needed without affecting other tests. |  27 # test as needed without affecting other tests. | 
|  28 @pytest.fixture |  28 @pytest.fixture | 
|  29 def form_data(): |  29 def form_data(): | 
|  30     return { |  30     return { | 
|  31         'name': 'John Doe', |  31         'name': 'John Doe', | 
|  32         'email': 'john_doe@gmail.com', |  32         'email': 'john_doe@gmail.com', | 
|  33         'subject': 'Hello there!', |  33         'subject': 'Hello there!', | 
|  34         'message': 'Once upon a time\nthere lived a king.' |  34         'message': 'Once upon a time\nthere lived a king.', | 
|  35     } |  35     } | 
|  36  |  36  | 
|  37  |  37  | 
|  38 @pytest.fixture() |  38 @pytest.fixture() | 
|  39 def response_for(): |  39 def response_for(): | 
|  40     host, port = 'test.local', 80 |  40     host, port = 'test.local', 80 | 
|  41     urllib_intercept.install_opener() |  41     urllib_intercept.install_opener() | 
|  42     add_wsgi_intercept(host, port, lambda: handleRequest) |  42     add_wsgi_intercept(host, port, lambda: handleRequest) | 
|  43     url = 'http://{}:{}'.format(host, port) |  43     url = 'http://{}:{}'.format(host, port) | 
|  44  |  44  | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  84  |  84  | 
|  85  |  85  | 
|  86 def test_success(response_for, form_data, mocker): |  86 def test_success(response_for, form_data, mocker): | 
|  87     sm_mock = mocker.patch('sitescripts.formmail.web.formmail.sendMail') |  87     sm_mock = mocker.patch('sitescripts.formmail.web.formmail.sendMail') | 
|  88     assert response_for(form_data) == 'Message sent' |  88     assert response_for(form_data) == 'Message sent' | 
|  89     assert sm_mock.call_count == 1 |  89     assert sm_mock.call_count == 1 | 
|  90     params = sm_mock.call_args[0][1] |  90     params = sm_mock.call_args[0][1] | 
|  91     assert set(params.keys()) == set(form_data.keys()) | {'time'} |  91     assert set(params.keys()) == set(form_data.keys()) | {'time'} | 
|  92     for key, value in form_data.items(): |  92     for key, value in form_data.items(): | 
|  93         assert params[key] == value |  93         assert params[key] == value | 
| OLD | NEW |