Ejemplo n.º 1
0
 def test_read(self):
     permission = Permission(True)
     self.assertTrue(permission.get_read())
     permission.set_read(False)
     self.assertFalse(permission.get_read())
     permission.set_read(None)
     self.assertEqual(None, permission.get_read())
     permission = Permission(read=True)
     self.assertTrue(permission.get_read())
Ejemplo n.º 2
0
 def test_execute(self):
     permission = Permission(True, True)
     self.assertTrue(permission.get_execute())
     permission.set_execute(False)
     self.assertFalse(permission.get_execute())
     permission.set_execute(None)
     self.assertEqual(None, permission.get_execute())
     permission = Permission(execute=True)
     self.assertTrue(permission.get_execute())
Ejemplo n.º 3
0
 def test_write(self):
     permission = Permission(True, True, False, False, False)
     self.assertFalse(permission.get_write())
     permission.set_write(True)
     self.assertTrue(permission.get_write())
     permission.set_write(None)
     self.assertEqual(None, permission.get_write())
     permission = Permission(write=True)
     self.assertTrue(permission.get_write())
Ejemplo n.º 4
0
    def test_from_lxml_full(self):
        text = '''
<CONDITION name="name" value="value" not="yes" regex="yes">
  <PERMISSION />
  <RETURN />
</CONDITION>'''
        condition = Condition.from_lxml_element(etree.XML(text))
        right = Condition('name', 'value', True, True,
                          [Permission(), Return()])
        self.assertEqual(condition, right)
Ejemplo n.º 5
0
 def test_creation(self):
     permission = Permission()
     permission = Permission(True)
     permission = Permission(True, True)
     permission = Permission(True, True, True)
     permission = Permission(True, True, True, True)
     permission = Permission(True, True, True, True, True)
Ejemplo n.º 6
0
 def test_from_string_write(self):
     text = '<PERMISSION WRITE="NO" />'
     permission = Permission.from_string(text)
     right = Permission(write=False)
     self.assertEqual(permission, right)
Ejemplo n.º 7
0
 def test_to_lxml_full(self):
     permission = Permission(True, False, True, False, True)
     copy = Permission.from_lxml_element(permission.to_lxml_element())
     self.assertEqual(permission, copy)
Ejemplo n.º 8
0
 def test_to_string_full(self):
     permission = Permission(True, False, True, False, True)
     copy = Permission.from_string(str(permission))
     self.assertEqual(permission, copy)
Ejemplo n.º 9
0
 def test_to_string_read(self):
     permission = Permission(read=True)
     copy = Permission.from_string(str(permission))
     self.assertEqual(permission, copy)
Ejemplo n.º 10
0
 def test_from_lxml_write(self):
     text = '<PERMISSION WRITE="NO" />'
     permission = Permission.from_lxml_element(etree.XML(text))
     right = Permission(write=False)
     self.assertEqual(permission, right)
Ejemplo n.º 11
0
 def test_from_lxml_read(self):
     text = '<PERMISSION READ="NO" />'
     permission = Permission.from_lxml_element(etree.XML(text))
     right = Permission(read=False)
     self.assertEqual(permission, right)
Ejemplo n.º 12
0
 def test_to_lxml_full(self):
     condition = Condition('name', 'value', True, True,
                           [Permission(), Return()])
     copy = Condition.from_lxml_element(condition.to_lxml_element())
     self.assertEqual(condition, copy)
Ejemplo n.º 13
0
 def test_to_lxml_sub_elements(self):
     condition = Condition(sub_elements=[Permission(), Return()])
     copy = Condition.from_lxml_element(condition.to_lxml_element())
     self.assertEqual(condition, copy)
Ejemplo n.º 14
0
 def test_to_string_full(self):
     condition = Condition('name', 'value', True, True,
                           [Permission(), Return()])
     copy = Condition.from_string(str(condition))
     self.assertEqual(condition, copy)
Ejemplo n.º 15
0
 def test_to_string_sub_elements(self):
     condition = Condition(sub_elements=[Permission(), Return()])
     copy = Condition.from_string(str(condition))
     self.assertEqual(condition, copy)
Ejemplo n.º 16
0
    def test_from_string_full(self):
        text = '''
<PERMISSION READ="NO" EXECUTE="YES" BROWSE="NO" DELETE="YES" WRITE="NO" />'''
        permission = Permission.from_string(text)
        right = Permission(False, True, False, True, False)
        self.assertEqual(permission, right)
Ejemplo n.º 17
0
 def test_from_lxml(self):
     text = '<PERMISSION />'
     permission = Permission.from_lxml_element(etree.XML(text))
     right = Permission()
     self.assertEqual(permission, right)
Ejemplo n.º 18
0
 def test_equality(self):
     self.assertEqual(Permission(False, False, False, False, False),
                      Permission(False, False, False, False, False))
     self.assertNotEqual(Permission(False, False, False, False, False),
                         Permission(True, False, False, False, False))
     self.assertNotEqual(Permission(False, False, False, False, False),
                         Permission(False, True, False, False, False))
     self.assertNotEqual(Permission(False, False, False, False, False),
                         Permission(False, False, True, False, False))
     self.assertNotEqual(Permission(False, False, False, False, False),
                         Permission(False, False, False, True, False))
     self.assertNotEqual(Permission(False, False, False, False, False),
                         Permission(False, False, False, False, True))
     self.assertNotEqual(Permission(), 'another type')
Ejemplo n.º 19
0
 def test_from_lxml_browse(self):
     text = '<PERMISSION BROWSE="NO" />'
     permission = Permission.from_lxml_element(etree.XML(text))
     right = Permission(browse=False)
     self.assertEqual(permission, right)
Ejemplo n.º 20
0
 def test_from_string(self):
     text = '<PERMISSION />'
     permission = Permission.from_string(text)
     right = Permission()
     self.assertEqual(permission, right)
Ejemplo n.º 21
0
    def test_from_lxml_full(self):
        text = '''
<PERMISSION READ="NO" EXECUTE="YES" BROWSE="NO" DELETE="YES" WRITE="NO" />'''
        permission = Permission.from_lxml_element(etree.XML(text))
        right = Permission(False, True, False, True, False)
        self.assertEqual(permission, right)
Ejemplo n.º 22
0
 def test_from_string_read(self):
     text = '<PERMISSION READ="NO" />'
     permission = Permission.from_string(text)
     right = Permission(read=False)
     self.assertEqual(permission, right)
Ejemplo n.º 23
0
 def test_to_string_write(self):
     permission = Permission(write=True)
     copy = Permission.from_string(str(permission))
     self.assertEqual(permission, copy)
Ejemplo n.º 24
0
 def test_from_string_execute(self):
     text = '<PERMISSION EXECUTE="NO" />'
     permission = Permission.from_string(text)
     right = Permission(execute=False)
     self.assertEqual(permission, right)
Ejemplo n.º 25
0
 def test_to_lxml_write(self):
     permission = Permission(write=True)
     copy = Permission.from_lxml_element(permission.to_lxml_element())
     self.assertEqual(permission, copy)
Ejemplo n.º 26
0
 def test_from_string_browse(self):
     text = '<PERMISSION BROWSE="NO" />'
     permission = Permission.from_string(text)
     right = Permission(browse=False)
     self.assertEqual(permission, right)
Ejemplo n.º 27
0
 def test_creation(self):
     slist = SecurityList()
     slist = SecurityList([Permission(), Return()])
Ejemplo n.º 28
0
 def test_from_lxml_sub_elements(self):
     text = '<CONDITION><PERMISSION /><RETURN /></CONDITION>'
     condition = Condition.from_lxml_element(etree.XML(text))
     right = Condition(sub_elements=[Permission(), Return()])
     self.assertEqual(condition, right)