Пример #1
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), [])
Пример #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), [])
Пример #3
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)
Пример #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)
Пример #5
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)
Пример #6
0
 def test_to_string(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_string(str(mimes))
     self.assertEqual(mimes, copy)
Пример #7
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)
Пример #8
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)
Пример #9
0
 def test_to_string(self):
     mimes = MIMETypes.from_string(self.text)
     copy = MIMETypes.from_string(str(mimes))
     self.assertEqual(mimes, copy)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #14
0
 def get_MIME_type_configuration(self):
     '''Get MIME types settings.'''
     return MIMETypes.from_string(self.get_file('&&&mime'))
Пример #15
0
 def get_MIME_type_configuration(self):
     '''Get MIME types settings.'''
     return MIMETypes.from_string(self.get_file('&&&mime'))