Put testtools directly under lib/ to make it easier to install from Samba 4.
[nivanova/samba-autobuild/.git] / lib / testtools / tests / test_content_type.py
1 # Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details.
2
3 import unittest
4 from testtools.content_type import ContentType
5
6
7 def test_suite():
8     from unittest import TestLoader
9     return TestLoader().loadTestsFromName(__name__)
10
11
12 class TestContentType(unittest.TestCase):
13
14     def test___init___None_errors(self):
15         self.assertRaises(ValueError, ContentType, None, None)
16         self.assertRaises(ValueError, ContentType, None, "traceback")
17         self.assertRaises(ValueError, ContentType, "text", None)
18
19     def test___init___sets_ivars(self):
20         content_type = ContentType("foo", "bar")
21         self.assertEqual("foo", content_type.type)
22         self.assertEqual("bar", content_type.subtype)
23         self.assertEqual({}, content_type.parameters)
24
25     def test___init___with_parameters(self):
26         content_type = ContentType("foo", "bar", {"quux":"thing"})
27         self.assertEqual({"quux":"thing"}, content_type.parameters)
28
29     def test___eq__(self):
30         content_type1 = ContentType("foo", "bar", {"quux":"thing"})
31         content_type2 = ContentType("foo", "bar", {"quux":"thing"})
32         content_type3 = ContentType("foo", "bar", {"quux":"thing2"})
33         self.assertTrue(content_type1.__eq__(content_type2))
34         self.assertFalse(content_type1.__eq__(content_type3))