示例#1
0
    def test_Signature_to_selector(self):
        s = Signature(id='1234')
        self.assertEqual(s.to_selector(), {'id': '1234'})
        self.assertIsInstance(s.to_selector(), dict)

        s = Signature(name='jdoe')
        self.assertEqual(s.to_selector(), {'name': 'jdoe'})

        s = Signature(id='1234', name='jdoe')
        self.assertEqual(s.to_selector(), {'id': '1234'})
示例#2
0
    def test_get_a_signature_by_id(self):
        sig1 = self.zc.create_signature('unittest', 'CONTENT', "text/html")
        sig2 = self.zc.create_signature('unittest1', 'CONTENT', "text/html")

        resp = self.zc.get_signature(Signature(id=sig1.id))
        self.assertIsInstance(resp, Signature)
        self.assertEqual(resp, sig1)

        resp = self.zc.get_signature(Signature(id=sig2.id))
        self.assertIsInstance(resp, Signature)
        self.assertEqual(resp, sig2)
示例#3
0
    def test_get_a_signature_by_name(self):
        sig1 = self.zc.create_signature('unittest', 'CONTENT', "text/html")
        self.zc.create_signature('unittest1', 'CONTENT', "text/html")

        resp = self.zc.get_signature(Signature(name='unittest'))
        self.assertIsInstance(resp, Signature)
        self.assertEqual(resp, sig1)
示例#4
0
    def test_Signature_to_selector(self):
        s = Signature(id="1234")
        self.assertEqual(s.to_selector(), {"id": "1234"})
        self.assertIsInstance(s.to_selector(), dict)

        s = Signature(name="jdoe")
        self.assertEqual(s.to_selector(), {"name": "jdoe"})

        s = Signature(id="1234", name="jdoe")
        self.assertEqual(s.to_selector(), {"id": "1234"})
示例#5
0
    def test_Signature_to_selector(self):
        s = Signature(id='1234')
        self.assertEqual(s.to_selector(), {'id': '1234'})
        self.assertIsInstance(s.to_selector(), dict)

        s = Signature(name='jdoe')
        self.assertEqual(s.to_selector(), {'name': 'jdoe'})

        s = Signature(id='1234', name='jdoe')
        self.assertEqual(s.to_selector(), {'id': '1234'})
示例#6
0
    def test_get_a_signature_by_name_case_insensitive(self):
        """ Zimbra considers that the signature name should be unique

        two signatures with same name, diferently cased is not allowed, so it's
        logical to be able to query a signature with any case.
        """
        sig1 = self.zc.create_signature('unittest', 'CONTENT', "text/html")
        self.zc.create_signature('unittest1', 'CONTENT', "text/html")

        resp = self.zc.get_signature(Signature(name='unitTEST'))
        self.assertIsInstance(resp, Signature)
        self.assertEqual(resp, sig1)
示例#7
0
 def test_delete_signature_by_id(self):
     sig = self.test_create_signature()
     self.zc.delete_signature(Signature(name=sig.name))
示例#8
0
    def test_Signature_set_content(self):
        s = Signature(name='unittest')
        s.set_content('TEST_CONTENT', contenttype='text/plain')

        self.assertEqual(s._contenttype, 'text/plain')
        self.assertEqual(s._content, 'TEST_CONTENT')
示例#9
0
 def test_Signature_dict_import(self):
     s = Signature.from_dict(self.signature_dict['signature'])
     self.assertIsInstance(s, Signature)
     self.assertIsInstance(s.get_content(), (text_type, binary_type))
     self.assertEqual(s.get_content(), 'CONTENT')
     self.assertEqual(s.get_content_type(), 'text/html')
示例#10
0
 def test_delete_signature_by_name(self):
     sig = self.test_create_signature()
     self.zc.delete_signature(Signature(id=sig.id))
示例#11
0
 def test_Signature_creator_default_format(self):
     s = Signature(name="unittest")
     s.set_content("TEST_CONTENT")
     self.assertEqual(s._contenttype, "text/html")
示例#12
0
 def test_Signature_creator_success(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT', contenttype='text/plain')
     d = s.to_creator()
     self.assertTrue(d['content'], 'TEST_CONTENT')
示例#13
0
 def test_Signature_creator_default_format(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT')
     self.assertEqual(s._contenttype, 'text/html')
示例#14
0
 def test_Signature_creator_default_format(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT')
     self.assertEqual(s._contenttype, 'text/html')
示例#15
0
 def test_modify_signature_without_id_attribute_error(self):
     sig1 = Signature(name='foo')
     sig1.set_content('NEW-CONTENT', "text/plain")
     with self.assertRaises(AttributeError):
         self.zc.modify_signature(sig1)
示例#16
0
 def test_Signature_creator_success(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT', contenttype='text/plain')
     d = s.to_creator()
     self.assertTrue(d['content'], 'TEST_CONTENT')
示例#17
0
 def test_Signature_dict_import(self):
     s = Signature.from_dict(self.signature_dict["signature"])
     self.assertIsInstance(s, Signature)
     self.assertIsInstance(s.get_content(), (text_type, binary_type))
     self.assertEqual(s.get_content(), "CONTENT")
     self.assertEqual(s.get_content_type(), "text/html")
示例#18
0
 def test_Signature_creator_success(self):
     s = Signature(name="unittest")
     s.set_content("TEST_CONTENT", contenttype="text/plain")
     d = s.to_creator()
     self.assertTrue(d["content"], "TEST_CONTENT")
示例#19
0
    def test_Signature_set_content(self):
        s = Signature(name="unittest")
        s.set_content("TEST_CONTENT", contenttype="text/plain")

        self.assertEqual(s._contenttype, "text/plain")
        self.assertEqual(s._content, "TEST_CONTENT")
示例#20
0
 def test_get_a_signature_by_nonexistant_name_returns_none(self):
     resp = self.zc.get_signature(Signature(name='idonotexist'))
     self.assertEqual(resp, None)
示例#21
0
    def test_Signature_set_content(self):
        s = Signature(name='unittest')
        s.set_content('TEST_CONTENT', contenttype='text/plain')

        self.assertEqual(s._contenttype, 'text/plain')
        self.assertEqual(s._content, 'TEST_CONTENT')
示例#22
0
 def test_get_a_signature_by_nonexistant_id_returns_none(self):
     resp = self.zc.get_signature(
         Signature(id='42428c6a-d764-479f-ae7d-d2d626b44242'))
     self.assertEqual(resp, None)
示例#23
0
 def test_Signature_creator_fails_without_content(self):
     s = Signature(name="unittest")
     with self.assertRaises(AttributeError):
         s.to_xml_creator()
示例#24
0
 def test_modify_signature_without_id_attribute_error(self):
     sig1 = Signature(name='foo')
     sig1.set_content('NEW-CONTENT', "text/plain")
     with self.assertRaises(AttributeError):
         self.zc.modify_signature(sig1)
示例#25
0
 def test_Signature_creator_fails_without_content(self):
     s = Signature(name='unittest')
     with self.assertRaises(AttributeError):
         s.to_xml_creator()