~bzr/ubuntu/natty/python-testtools/bzr-ppa

« back to all changes in this revision

Viewing changes to testtools/tests/test_content_type.py

  • Committer: Robert Collins
  • Date: 2009-11-22 03:48:30 UTC
  • mfrom: (16.11.1 upstream)
  • Revision ID: robertc@robertcollins.net-20091122034830-itaynkycem2mchy9
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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))