Exemplo n.º 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'})
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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"})
Exemplo n.º 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'})
Exemplo n.º 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)
Exemplo n.º 7
0
 def test_delete_signature_by_id(self):
     sig = self.test_create_signature()
     self.zc.delete_signature(Signature(name=sig.name))
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 10
0
 def test_delete_signature_by_name(self):
     sig = self.test_create_signature()
     self.zc.delete_signature(Signature(id=sig.id))
Exemplo n.º 11
0
 def test_Signature_creator_default_format(self):
     s = Signature(name="unittest")
     s.set_content("TEST_CONTENT")
     self.assertEqual(s._contenttype, "text/html")
Exemplo n.º 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')
Exemplo n.º 13
0
 def test_Signature_creator_default_format(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT')
     self.assertEqual(s._contenttype, 'text/html')
Exemplo n.º 14
0
 def test_Signature_creator_default_format(self):
     s = Signature(name='unittest')
     s.set_content('TEST_CONTENT')
     self.assertEqual(s._contenttype, 'text/html')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 23
0
 def test_Signature_creator_fails_without_content(self):
     s = Signature(name="unittest")
     with self.assertRaises(AttributeError):
         s.to_xml_creator()
Exemplo n.º 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)
Exemplo n.º 25
0
 def test_Signature_creator_fails_without_content(self):
     s = Signature(name='unittest')
     with self.assertRaises(AttributeError):
         s.to_xml_creator()