Exemplo n.º 1
0
    def test_barometer(self):
        jingo.load_helpers()
        collection = Collection.objects.get(pk=57274)
        collection.up_votes = 1
        # Mock logged out.
        c = dict(request=Mock())
        c["request"].path = "yermom"
        c["request"].user.is_authenticated = lambda: False
        doc = pq(barometer(c, collection))
        eq_(doc("form")[0].action, "/users/login?to=yermom")

        # Mock logged in.
        c["request"].amo_user.votes.filter = lambda collection: [1]
        c["request"].user.is_authenticated = lambda: True
        barometer(c, collection)
        doc = pq(barometer(c, collection))
        eq_(doc("form")[0].action, remora_url("collections/vote/%s/up" % collection.uuid))
Exemplo n.º 2
0
    def test_barometer(self):
        jingo.load_helpers()
        collection = Collection.objects.get(pk=57274)
        collection.upvotes = 1
        # Mock logged out.
        c = dict(request=Mock(), user=Mock(), LANG='en-US', APP='firefox')
        c['request'].path = 'yermom'
        c['request'].GET.urlencode = lambda: ''
        c['request'].user.is_authenticated = lambda: False
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action, '/en-US/firefox/users/login?to=yermom')

        # Mock logged in.
        vote = Mock()
        vote.vote = 1
        c['request'].amo_user.votes.filter.return_value = [vote]
        c['request'].user.is_authenticated = lambda: True
        barometer(c, collection)
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action,
            reverse('collections.vote', args=['anonymous', None, 'up']))
Exemplo n.º 3
0
    def test_barometer(self):
        jingo.load_helpers()
        collection = Collection.objects.get(pk=80)
        collection.upvotes = 1
        # Mock logged out.
        c = dict(request=Mock(), user=Mock(), LANG='en-US', APP='firefox')
        c['request'].path = 'yermom'
        c['request'].GET.urlencode = lambda: ''
        c['request'].user.is_authenticated = lambda: False
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action, '/en-US/firefox/users/login?to=yermom')

        # Mock logged in.
        vote = Mock()
        vote.vote = 1
        c['request'].amo_user.votes.filter.return_value = [vote]
        c['request'].user.is_authenticated = lambda: True
        barometer(c, collection)
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action,
            reverse('collections.vote', args=['clouserw', 'mccrackin', 'up']))
Exemplo n.º 4
0
    def test_barometer(self):
        self.client.get('/')
        jingo.load_helpers()
        collection = Collection(upvotes=1, slug='mccrackin',
                                author=UserProfile(username='******'))
        # Mock logged out.
        c = {
            'request': Mock(path='yermom', GET=Mock(urlencode=lambda: '')),
            'user': Mock(),
            'settings': Mock()
        }
        c['request'].user.is_authenticated.return_value = False
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action, '/en-US/firefox/users/login?to=yermom')

        # Mock logged in.
        c['request'].user.votes.filter.return_value = [Mock(vote=1)]
        c['request'].user.is_authenticated.return_value = True
        barometer(c, collection)
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action,
            reverse('collections.vote', args=['clouserw', 'mccrackin', 'up']))
Exemplo n.º 5
0
    def test_barometer(self):
        self.client.get('/')
        jingo.load_helpers()
        collection = Collection(upvotes=1,
                                slug='mccrackin',
                                author=UserProfile(username='******'))
        # Mock logged out.
        c = {
            'request': Mock(path='yermom', GET=Mock(urlencode=lambda: '')),
            'user': Mock(),
            'settings': Mock()
        }
        c['request'].user.is_authenticated.return_value = False
        doc = pq(barometer(c, collection))
        eq_(doc('form')[0].action, '/en-US/firefox/users/login?to=yermom')

        # Mock logged in.
        c['request'].amo_user.votes.filter.return_value = [Mock(vote=1)]
        c['request'].user.is_authenticated.return_value = True
        barometer(c, collection)
        doc = pq(barometer(c, collection))
        eq_(
            doc('form')[0].action,
            reverse('collections.vote', args=['clouserw', 'mccrackin', 'up']))