Ejemplo n.º 1
0
    def test_adding_scopes_preserves_originals(self):
        s1 = Scope('b', 'a')
        s2 = Scope('c', 'b')

        assert isinstance(s1 + s2, Scope)
        assert s1 + s2 == {'a', 'b', 'c'}
        assert str(s1) == 'a b'
        assert str(s2) == 'b c'
Ejemplo n.º 2
0
    def test_subtracting_scopes_preservers_originals(self):
        s1 = Scope('b', 'a')
        s2 = Scope('c', 'b')

        assert isinstance(s1 - s2, Scope)
        assert s1 - s2 == {'a'}
        assert str(s1) == 'a b'
        assert str(s2) == 'b c'
Ejemplo n.º 3
0
 def test_scope_initialisable_with_combination(self):
     s = Scope('a', 'b', scope.user_read_private)
     assert str(s) == 'a b user-read-private'
Ejemplo n.º 4
0
 def test_scope_initialisable_with_enum(self):
     s = Scope(scope.user_read_private)
     assert str(s) == 'user-read-private'
Ejemplo n.º 5
0
 def test_scope_initialisable_with_strings(self):
     s = Scope('b', 'a')
     assert str(s) == 'a b'
Ejemplo n.º 6
0
 def test_add_Scope_Scope(self):
     s = Scope('a') + Scope('b')
     assert str(s) == 'a b'
Ejemplo n.º 7
0
 def test_add_scope_Scope(self):
     s = scope.user_top_read + Scope('a')
     assert str(s) == 'a user-top-read'
Ejemplo n.º 8
0
 def test_add_invalid_Scope(self):
     with pytest.raises(NotImplementedError):
         1 + Scope('a')
Ejemplo n.º 9
0
 def test_sub_Scope_scope_same(self):
     s = Scope('user-top-read') - scope.user_top_read
     assert str(s) == ''
Ejemplo n.º 10
0
 def test_sub_Scope_scope_different(self):
     s = Scope('a') - scope.user_top_read
     assert str(s) == 'a'
Ejemplo n.º 11
0
 def test_sub_Scope_str_different(self):
     s = Scope('a') - 'b'
     assert str(s) == 'a'
Ejemplo n.º 12
0
 def test_sub_scope_Scope_different(self):
     s = scope.user_top_read - Scope('a')
     assert str(s) == 'user-top-read'
Ejemplo n.º 13
0
 def test_repr_like_instantiation(self):
     s = Scope('a', 'b')
     assert repr(s) == "Scope('a', 'b')"
Ejemplo n.º 14
0
 def test_sub_str_Scope_same(self):
     s = 'a' - Scope('a')
     assert str(s) == ''
Ejemplo n.º 15
0
 def test_sub_str_Scope_different(self):
     s = 'a' - Scope('b')
     assert str(s) == 'a'
Ejemplo n.º 16
0
 def test_different_object_same_str_results_in_no_duplicates(self):
     s = Scope(scope.user_read_private, 'user-read-private')
     assert s == {'user-read-private'}
Ejemplo n.º 17
0
 def test_scope_unpackable(self):
     s1 = Scope('b', 'a')
     s2 = Scope(*s1)
     assert s1 == s2
Ejemplo n.º 18
0
 def test_sub_Scope_Scope_different(self):
     s = Scope('a') - Scope('b')
     assert str(s) == 'a'
Ejemplo n.º 19
0
 def test_sub_Scope_Scope_same(self):
     s = Scope('a') - Scope('a')
     assert str(s) == ''
Ejemplo n.º 20
0
 def test_sub_Scope_invalid_raises(self):
     with pytest.raises(NotImplementedError):
         Scope('a') - 1
Ejemplo n.º 21
0
 def test_add_str_Scope(self):
     s = 'a' + Scope('b')
     assert str(s) == 'a b'
Ejemplo n.º 22
0
 def test_empty_scope_equal_to_empty_set(self):
     s = Scope()
     assert s == set()
Ejemplo n.º 23
0
 def test_add_Scope_str(self):
     s = Scope('a') + 'b'
     assert str(s) == 'a b'
Ejemplo n.º 24
0
 def test_add_Scope_scope(self):
     s = Scope('a') + scope.user_top_read
     assert str(s) == 'a user-top-read'