# -*- coding: utf-8 -*-1# This program is free software; you can redistribute it and/or modify2# it under the terms of the GNU General Public License as published by3# the Free Software Foundation; either version 2 of the License, or4# (at your option) any later version.5#6# This program is distributed in the hope that it will be useful,7# but WITHOUT ANY WARRANTY; without even the implied warranty of8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9# GNU General Public License for more details.10#11# You should have received a copy of the GNU General Public License12# along with this program; if not, write to the Free Software13# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,14# MA 02110-1301, USA.15#16# Author: Mauro Soria1718from unittest import TestCase1920from lib.parse.headers import HeadersParser212223class TestHeadersParser(TestCase):24def test_str_to_dict(self):25test_str = """26Header1: foo27Header2:bar28Header3:29"""30expected_dict = {"Header1": "foo", "Header2": "bar", "Header3": ""}31self.assertEqual(HeadersParser.str_to_dict(test_str.strip()), expected_dict, "Raw headers to dictionary converter gives unexpected result")3233def test_dict_to_str(self):34test_dict = {"foo": "bar"}35expected_str = "foo: bar"36self.assertEqual(HeadersParser.dict_to_str(test_dict), expected_str, "Headers dictionary to raw converter gives unexpected result")373839