pytilities.test.delegation.profile

Package pytilities :: Package test :: Package delegation :: Module profile |
[hide private]
[frames] | no frames]

# Source Code for Module pytilities.test.delegation.profile

     1  # Copyright (C) 2010 Tim Diels <limyreth@users.sourceforge.net>
     2  #
     3  # This file is part of pytilities.
     4  #
     5  # pytilities is free software: you can redistribute it and/or modify
     6  # it under the terms of the GNU General Public License as published by
     7  # the Free Software Foundation, either version 3 of the License, or
     8  # (at your option) any later version.
     9  #
    10  # pytilities is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  # GNU General Public License for more details.
    14  #
    15  # You should have received a copy of the GNU General Public License
    16  # along with pytilities.  If not, see <http://www.gnu.org/licenses/>.
    17  #
    18
    19  __docformat__ = 'reStructuredText'
    20
    21  import unittest
    22
    23  from pytilities.delegation import Profile
    24
    25 -class MainTestCase(unittest.TestCase):
    26 -    def test_public(self):
    27          # these should conflict
    28          a = Profile()
    29          b = Profile()
    30          a.add_mappings('rw', *'a b c'.split(), d='d')
    31          b.add_mappings('rw', *'a b'.split(), d='e')
    32
    33          # care about conflict
    34          self.assertRaises(AssertionError, lambda: a | b)
    35          self.assertRaises(AssertionError, lambda: a & b)
    36
    37          # don't care, shouldn't raise
    38          c = a - b
    39          c = a ^ b
    40
    41          # these shouldn't conflict either
    42          a = Profile()
    43          b = Profile()
    44          a.add_mappings('rw', 'a', c='d')
    45          a.add_mappings('w', 'b')
    46          b.add_mappings('rw', 'a', d='e')
    47          b.add_mappings('r', 'b')
    48
    49          c = a | b
    50          self.assert_(c.has_readable('a'))
    51          self.assert_(c.has_readable('b'))
    52          self.assert_(c.has_readable('c'))
    53          self.assert_(c.has_readable('d'))
    54          self.assert_(c.has_writable('a'))
    55          self.assert_(c.has_writable('b'))
    56          self.assert_(c.has_writable('c'))
    57          self.assert_(c.has_writable('d'))
    58
    59          c = a & b
    60          self.assert_(c.has_readable('a'))
    61          self.assert_(c.has_writable('a'))
    62
    63          c = a - b
    64          self.assert_(c.has_readable('c'))
    65          self.assert_(c.has_writable('b'))
    66          self.assert_(c.has_writable('c'))
    67
    68          c = a ^ b
    69          self.assert_(c.has_readable('b'))
    70          self.assert_(c.has_readable('c'))
    71          self.assert_(c.has_readable('d'))
    72          self.assert_(c.has_writable('b'))
    73          self.assert_(c.has_writable('c'))
    74          self.assert_(c.has_writable('d'))
    75
    76          # check for existance of other operators
    77          c = a.copy()
    78          c |= b
    79
    80          c = a.copy()
    81          c &= b
    82
    83          c = a.copy()
    84          c -= b
    85
    86          c = a.copy()
    87          c ^= b
    88