X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=lib%2Ftesttools%2Ftests%2Ftest_content_type.py;fp=lib%2Ftesttools%2Ftests%2Ftest_content_type.py;h=dbefc21decf6e45bcb06f4acd7f4501e0ed3efb3;hb=a8ac7fda573a924debf165d39eff3c1837240d4f;hp=0000000000000000000000000000000000000000;hpb=e4af3afd7ae3e39218b42a42d39c2ec10be9a642;p=nivanova%2Fsamba-autobuild%2F.git diff --git a/lib/testtools/tests/test_content_type.py b/lib/testtools/tests/test_content_type.py new file mode 100644 index 00000000000..dbefc21decf --- /dev/null +++ b/lib/testtools/tests/test_content_type.py @@ -0,0 +1,34 @@ +# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details. + +import unittest +from testtools.content_type import ContentType + + +def test_suite(): + from unittest import TestLoader + return TestLoader().loadTestsFromName(__name__) + + +class TestContentType(unittest.TestCase): + + def test___init___None_errors(self): + self.assertRaises(ValueError, ContentType, None, None) + self.assertRaises(ValueError, ContentType, None, "traceback") + self.assertRaises(ValueError, ContentType, "text", None) + + def test___init___sets_ivars(self): + content_type = ContentType("foo", "bar") + self.assertEqual("foo", content_type.type) + self.assertEqual("bar", content_type.subtype) + self.assertEqual({}, content_type.parameters) + + def test___init___with_parameters(self): + content_type = ContentType("foo", "bar", {"quux":"thing"}) + self.assertEqual({"quux":"thing"}, content_type.parameters) + + def test___eq__(self): + content_type1 = ContentType("foo", "bar", {"quux":"thing"}) + content_type2 = ContentType("foo", "bar", {"quux":"thing"}) + content_type3 = ContentType("foo", "bar", {"quux":"thing2"}) + self.assertTrue(content_type1.__eq__(content_type2)) + self.assertFalse(content_type1.__eq__(content_type3))