def test_it_should_not_allow_someone_you_have_blocked_to_follow_you(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.block(1, 11)

        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['following_key'],
             Amico.DEFAULTS['default_scope_key'],
             11)).should.equal(0)
        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['blocked_key'],
             Amico.DEFAULTS['default_scope_key'],
             1)).should.equal(1)

        amico.follow(11, 1)

        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['following_key'],
             Amico.DEFAULTS['default_scope_key'],
             11)).should.equal(0)
        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['blocked_key'],
             Amico.DEFAULTS['default_scope_key'],
             1)).should.equal(1)
    def test_it_should_clear_blocked_blocked_by_relationships(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.block(1, 11)
        amico.blocked_count(1).should.equal(1)
        amico.blocked_by_count(11).should.equal(1)

        amico.clear(11)

        amico.blocked_count(1).should.equal(0)
        amico.blocked_by_count(11).should.equal(0)
 def test_it_should_remove_the_pending_relationship_if_you_block_someone(
         self):
     amico = Amico(
         options={
             'pending_follow': True},
         redis_connection=self.redis_connection)
     amico.follow(11, 1)
     amico.is_pending(11, 1).should.be.true
     amico.is_pending_with(1, 11).should.be.true
     amico.block(1, 11)
     amico.is_pending(11, 1).should.be.false
     amico.is_pending_with(1, 11).should.be.false
     amico.is_blocked(1, 11).should.be.true
 def test_it_should_allow_you_to_block_someone_you_have_blocked(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.block(1, 11)
     amico.is_blocked(1, 11).should.be.true
     amico.redis_connection.zcard(
         '%s:%s:%s:%s' %
         (Amico.DEFAULTS['namespace'],
          Amico.DEFAULTS['blocked_by_key'],
          Amico.DEFAULTS['default_scope_key'],
          11)).should.equal(1)
     amico.unblock(1, 11)
     amico.is_blocked(1, 11).should.be.false
     amico.redis_connection.zcard(
         '%s:%s:%s:%s' %
         (Amico.DEFAULTS['namespace'],
          Amico.DEFAULTS['blocked_by_key'],
          Amico.DEFAULTS['default_scope_key'],
          11)).should.equal(0)
 def test_it_should_return_the_correct_blocked_by_list(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.block(11, 1)
     amico.block(12, 1)
     amico.blocked_by(1).should.equal(["12", "11"])
 def test_it_should_return_that_someone_is_blocking_you(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.block(1, 11)
     amico.is_blocked_by(11, 1).should.be.true
 def test_it_should_return_that_someone_is_being_blocked(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.block(1, 11)
     amico.is_blocked(1, 11).should.be.true
     amico.is_following(11, 1).should.be.false
    def test_it_should_not_allow_you_to_block_yourself(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.block(1, 1)

        amico.is_blocked(1, 1).should.be.false