def test_equality(self):
     self.assertEqual(MIMETypes.from_string(self.text),
                      MIMETypes.from_string(self.text))
     self.assertNotEqual(MIMETypes.from_string(self.text),
                         MIMETypes.from_string(
             '<MIMES>{0}</MIMES>'.format(self.mime_0)))
     self.assertNotEqual(MIMETypes.from_string(self.text), [])
Beispiel #2
0
 def test_equality(self):
     self.assertEqual(MIMETypes.from_string(self.text),
                      MIMETypes.from_string(self.text))
     self.assertNotEqual(
         MIMETypes.from_string(self.text),
         MIMETypes.from_string('<MIMES>{0}</MIMES>'.format(self.mime_0)))
     self.assertNotEqual(MIMETypes.from_string(self.text), [])
    def test_mime_types(self):
        text = '''
<MIMES custom="unknown">
  <MIME mime="text/plain" />
  <MIME mime="text/html" />
  <UNKNOWN>
    <CUSTOM />
  </UNKNOWN>
</MIMES>'''
        mimes = MIMETypes.from_string(text)
        tree = mimes.to_lxml_element()
        self.assertEqual('unknown', tree.get('custom'))
        self.assertEqual(2, len(tree.findall('MIME')))
        unknown = tree.findall('UNKNOWN')
        self.assertEqual(1, len(unknown))
        unknown = unknown[0]
        custom = list(unknown)
        self.assertEqual(1, len(custom))
        custom = custom[0]
        self.assertEqual('CUSTOM', custom.tag)
Beispiel #4
0
    def test_mime_types(self):
        text = '''
<MIMES custom="unknown">
  <MIME mime="text/plain" />
  <MIME mime="text/html" />
  <UNKNOWN>
    <CUSTOM />
  </UNKNOWN>
</MIMES>'''
        mimes = MIMETypes.from_string(text)
        tree = mimes.to_lxml_element()
        self.assertEqual('unknown', tree.get('custom'))
        self.assertEqual(2, len(tree.findall('MIME')))
        unknown = tree.findall('UNKNOWN')
        self.assertEqual(1, len(unknown))
        unknown = unknown[0]
        custom = list(unknown)
        self.assertEqual(1, len(custom))
        custom = custom[0]
        self.assertEqual('CUSTOM', custom.tag)
 def test_to_lxml(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_lxml_element(mimes.to_lxml_element())
     self.assertEqual(mimes, copy)
 def test_to_string(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_string(str(mimes))
     self.assertEqual(mimes, copy)
 def test_from_lxml(self):
     mimes = MIMETypes.from_lxml_element(etree.XML(self.text))
     self.assertEqual(mimes.MIME_types[0], self.mime_0)
     self.assertEqual(mimes.MIME_types[1], self.mime_1)
 def test_from_string(self):
     mimes = MIMETypes.from_string(self.text)
     self.assertEqual(mimes.MIME_types[0], self.mime_0)
     self.assertEqual(mimes.MIME_types[1], self.mime_1)
Beispiel #9
0
 def test_to_string(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_string(str(mimes))
     self.assertEqual(mimes, copy)
Beispiel #10
0
 def test_to_lxml(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_lxml_element(mimes.to_lxml_element())
     self.assertEqual(mimes, copy)
Beispiel #11
0
 def test_from_lxml(self):
     mimes = MIMETypes.from_lxml_element(etree.XML(self.text))
     self.assertEqual(mimes.MIME_types[0], self.mime_0)
     self.assertEqual(mimes.MIME_types[1], self.mime_1)
Beispiel #12
0
 def test_from_string(self):
     mimes = MIMETypes.from_string(self.text)
     self.assertEqual(mimes.MIME_types[0], self.mime_0)
     self.assertEqual(mimes.MIME_types[1], self.mime_1)
Beispiel #13
0
 def test_creation(self):
     mimes = MIMETypes([self.mime_0, self.mime_1])
     self.assertEqual(mimes.MIME_types[0], self.mime_0)
     self.assertEqual(mimes.MIME_types[1], self.mime_1)
Beispiel #14
0
 def get_MIME_type_configuration(self):
     '''Get MIME types settings.'''
     return MIMETypes.from_string(self.get_file('&&&mime'))
 def get_MIME_type_configuration(self):
     '''Get MIME types settings.'''
     return MIMETypes.from_string(self.get_file('&&&mime'))