|
| 1 | +# |
| 2 | +# MIT License |
| 3 | +# |
| 4 | +# Copyright (c) 2020 Airbyte |
| 5 | +# |
| 6 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +# of this software and associated documentation files (the "Software"), to deal |
| 8 | +# in the Software without restriction, including without limitation the rights |
| 9 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +# copies of the Software, and to permit persons to whom the Software is |
| 11 | +# furnished to do so, subject to the following conditions: |
| 12 | +# |
| 13 | +# The above copyright notice and this permission notice shall be included in all |
| 14 | +# copies or substantial portions of the Software. |
| 15 | +# |
| 16 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +# SOFTWARE. |
| 23 | +# |
| 24 | +from source_facebook_marketing.streams import remove_params_from_url |
| 25 | + |
| 26 | + |
| 27 | +class TestUrlParsing: |
| 28 | + def test_empty_url(self): |
| 29 | + url = "" |
| 30 | + parsed_url = remove_params_from_url(url=url, params=[]) |
| 31 | + assert parsed_url == url |
| 32 | + |
| 33 | + def test_does_not_raise_exception_for_invalid_url(self): |
| 34 | + url = "abcd" |
| 35 | + parsed_url = remove_params_from_url(url=url, params=["test"]) |
| 36 | + assert parsed_url == url |
| 37 | + |
| 38 | + def test_escaped_characters(self): |
| 39 | + url = "https://google.com?test=123%23%24%25%2A&test2=456" |
| 40 | + parsed_url = remove_params_from_url(url=url, params=["test3"]) |
| 41 | + assert parsed_url == url |
| 42 | + |
| 43 | + def test_no_params_url(self): |
| 44 | + url = "https://google.com" |
| 45 | + parsed_url = remove_params_from_url(url=url, params=["test"]) |
| 46 | + assert parsed_url == url |
| 47 | + |
| 48 | + def test_no_params_arg(self): |
| 49 | + url = "https://google.com?" |
| 50 | + parsed_url = remove_params_from_url(url=url, params=["test"]) |
| 51 | + assert parsed_url == "https://google.com" |
| 52 | + |
| 53 | + def test_partially_empty_params(self): |
| 54 | + url = "https://google.com?test=122&&" |
| 55 | + parsed_url = remove_params_from_url(url=url, params=[]) |
| 56 | + assert parsed_url == "https://google.com?test=122" |
| 57 | + |
| 58 | + def test_no_matching_params(self): |
| 59 | + url = "https://google.com?test=123" |
| 60 | + parsed_url = remove_params_from_url(url=url, params=["test2"]) |
| 61 | + assert parsed_url == url |
| 62 | + |
| 63 | + def test_removes_params(self): |
| 64 | + url = "https://google.com?test=123&test2=456" |
| 65 | + parsed_url = remove_params_from_url(url=url, params=["test2"]) |
| 66 | + assert parsed_url == "https://google.com?test=123" |
0 commit comments