Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_it_should_remove_the_pending_relationship_and_add_to_following_and_followers_if_accept_is_called_and_add_to_reciprocated_relationship(
            self):
        amico = Amico(
            options={
                'pending_follow': True},
            redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.follow(11, 1)
        amico.is_pending(1, 11).should.be.true
        amico.is_pending(11, 1).should.be.true

        amico.accept(1, 11)

        amico.is_pending(1, 11).should.be.false
        amico.is_pending(11, 1).should.be.true
        amico.is_following(1, 11).should.be.true
        amico.is_following(11, 1).should.be.false
        amico.is_follower(11, 1).should.be.true
        amico.is_follower(1, 11).should.be.false

        amico.accept(11, 1)

        amico.is_pending(1, 11).should.be.false
        amico.is_pending(11, 1).should.be.false
        amico.is_following(1, 11).should.be.true
        amico.is_following(11, 1).should.be.true
        amico.is_follower(11, 1).should.be.true
        amico.is_follower(1, 11).should.be.true
        amico.is_reciprocated(1, 11).should.be.true
Ejemplo n.º 3
0
 def test_it_should_return_true_if_both_individuals_are_following_each_other(
         self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.follow(1, 11)
     amico.is_reciprocated(1, 11).should.be.false
     amico.follow(11, 1)
     amico.is_reciprocated(1, 11).should.be.true
Ejemplo n.º 4
0
    def test_it_should_return_that_you_are_being_followed(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.is_follower(11, 1).should.be.true
        amico.is_follower(1, 11).should.be.false

        amico.follow(11, 1)
        amico.is_follower(1, 11).should.be.true
Ejemplo n.º 5
0
 def test_it_should_return_the_correct_pending_with_list(self):
     amico = Amico(
         options={
             'pending_follow': True},
         redis_connection=self.redis_connection)
     amico.follow(1, 11)
     amico.follow(11, 1)
     amico.pending_with(1).should.equal(["11"])
     amico.pending_with(11).should.equal(["1"])
Ejemplo n.º 6
0
 def test_it_should_respect_scope_when_checking_if_a_relationship_is_reciprocated(
         self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.follow(1, 11, scope='another_scope')
     amico.follow(11, 1, scope='another_scope')
     amico.is_reciprocated(1, 11).should.be.false
     amico.is_reciprocated(1, 11, scope='another_scope').should.be.true
     amico.follow(1, 11)
     amico.follow(11, 1)
     amico.is_reciprocated(1, 11).should.be.true
Ejemplo n.º 7
0
    def test_it_should_clear_pending_pending_with_relationships(self):
        amico = Amico(
            options={
                'pending_follow': True},
            redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.pending_count(11).should.equal(1)

        amico.clear(1)

        amico.pending_count(11).should.equal(0)
Ejemplo n.º 8
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
Ejemplo n.º 9
0
    def test_it_should_not_allow_you_to_follow_yourself(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.follow(1, 1)

        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['following_key'],
             Amico.DEFAULTS['default_scope_key'],
             1)).should.equal(0)
        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['followers_key'],
             Amico.DEFAULTS['default_scope_key'],
             1)).should.equal(0)
Ejemplo n.º 10
0
    def test_it_should_remove_the_pending_relationship_without_following_or_blocking(
            self):
        amico = Amico(
            options={
                'pending_follow': True},
            redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.is_pending(1, 11).should.be.true
        amico.is_pending_with(11, 1).should.be.true

        amico.deny(1, 11)

        amico.is_following(1, 11).should.be.false
        amico.is_pending(1, 11).should.be.false
        amico.is_pending_with(11, 1).should.be.false
        amico.is_blocked(1, 11).should.be.false
Ejemplo n.º 11
0
    def test_it_should_add_each_individual_to_the_reciprocated_set_if_you_both_follow_each_other(
            self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.follow(11, 1)

        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['reciprocated_key'],
             Amico.DEFAULTS['default_scope_key'],
             1)).should.equal(1)
        amico.redis_connection.zcard(
            '%s:%s:%s:%s' %
            (Amico.DEFAULTS['namespace'],
             Amico.DEFAULTS['reciprocated_key'],
             Amico.DEFAULTS['default_scope_key'],
             11)).should.equal(1)
Ejemplo n.º 12
0
    def test_it_should_remove_follower_and_following_relationships(self):
        amico = Amico(redis_connection=self.redis_connection)
        amico.follow(1, 11)
        amico.follow(11, 1)

        amico.following_count(1).should.equal(1)
        amico.followers_count(1).should.equal(1)
        amico.reciprocated_count(1).should.equal(1)
        amico.following_count(11).should.equal(1)
        amico.followers_count(11).should.equal(1)
        amico.reciprocated_count(11).should.equal(1)

        amico.clear(1)

        amico.following_count(1).should.equal(0)
        amico.followers_count(1).should.equal(0)
        amico.reciprocated_count(1).should.equal(0)
        amico.following_count(11).should.equal(0)
        amico.followers_count(11).should.equal(0)
        amico.reciprocated_count(11).should.equal(0)
Ejemplo n.º 13
0
 def test_it_should_return_the_correct_reciprocated_list(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.follow(1, 11)
     amico.follow(11, 1)
     amico.reciprocated(1).should.equal(["11"])
     amico.reciprocated(11).should.equal(["1"])
Ejemplo n.º 14
0
 def test_it_should_return_the_correct_followers_list(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.follow(1, 11)
     amico.follow(2, 11)
     amico.followers(11).should.equal(["2", "1"])
Ejemplo n.º 15
0
 def test_it_should_return_the_correct_following_list(self):
     amico = Amico(redis_connection=self.redis_connection)
     amico.follow(1, 11)
     amico.follow(1, 12)
     amico.following(1).should.equal(["12", "11"])