예제 #1
0
    def test_success(self):
        user = UserProfile.objects.get(email="*****@*****.**")
        self.client.login(username=user.email, password="******")
        r = self.client.get("/", follow=True)
        eq_(pq(r.content.decode("utf-8"))(".account .user").text(), user.display_name)
        eq_(pq(r.content)(".account .user").attr("title"), user.email)

        r = self.client.get("/users/logout", follow=True)
        assert not pq(r.content)(".account .user")
예제 #2
0
    def test_success(self):
        user = UserProfile.objects.get(email='*****@*****.**')
        self.client.login(username=user.email, password='******')
        r = self.client.get('/', follow=True)
        eq_(pq(r.content.decode('utf-8'))('.account .user').text(),
            user.display_name)
        eq_(pq(r.content)('.account .user').attr('title'), user.email)

        r = self.client.get('/users/logout', follow=True)
        assert not pq(r.content)('.account .user')
예제 #3
0
    def test_success(self):
        user = UserProfile.objects.get(email='*****@*****.**')
        self.client.login(username=user.email, password='******')
        r = self.client.get('/', follow=True)
        eq_(pq(r.content.decode('utf-8'))('.account .user').text(),
            user.display_name)
        eq_(pq(r.content)('.account .user').attr('title'), user.email)

        r = self.client.get('/users/logout', follow=True)
        assert not pq(r.content)('.account .user')
예제 #4
0
    def test_legacy_confirm(self):
        # User doesn't have a valid confirmation code.
        url = reverse("users.confirm", args=[self.user.id, "blah"])
        r = self.client.get(url, follow=True)
        # Ensure we don't show django messages for registrations via Remora.
        eq_(pq(r.content)(".notification-box").length, 0)

        self.user_profile.update(confirmationcode="code")

        url = reverse("users.confirm", args=[self.user.id, "code"])
        r = self.client.get(url, follow=True)
        eq_(pq(r.content)(".notification-box").length, 0)
예제 #5
0
    def test_success(self):
        res = self.client.get('/developers/', follow=True)
        data = pq(res.content.decode('utf-8'))('body').attr('data-user')
        data = json.loads(data)
        eq_(data['email'], self.user.email)
        eq_(data['anonymous'], False)

        res = self.client.get(reverse('users.logout'), follow=True)
        data = pq(res.content.decode('utf-8'))('body').attr('data-user')
        data = json.loads(data)
        eq_(data['email'], '')
        eq_(data['anonymous'], True)
예제 #6
0
    def test_my_personas(self):
        eq_(pq(self.client.get(self.url).content)(".num-addons a").length, 0)

        a = amo.tests.addon_factory(type=amo.ADDON_PERSONA)

        AddonUser.objects.create(user=self.user, addon=a)

        r = self.client.get(self.url)

        doc = pq(r.content)
        items = doc("#my-themes .persona")
        eq_(items.length, 1)
        eq_(items('a[href="%s"]' % a.get_url_path()).length, 1)
예제 #7
0
    def test_my_personas(self):
        eq_(pq(self.client.get(self.url).content)('.num-addons a').length, 0)

        a = amo.tests.addon_factory(type=amo.ADDON_PERSONA)

        AddonUser.objects.create(user=self.user, addon=a)

        r = self.client.get(self.url)

        doc = pq(r.content)
        items = doc('#my-themes .persona')
        eq_(items.length, 1)
        eq_(items('a[href="%s"]' % a.get_url_path()).length, 1)
예제 #8
0
    def test_loggedout_purchased(self):
        # "Buy" the add-on
        self.addon.addonpurchase_set.create(user=self.user.get_profile())

        # Make sure we get a log in field
        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)
        assert pq(r.content).find('#id_username').length

        # Now, let's log in.
        res = self.client.post_ajax(self.url, data=self.data)
        eq_(res.status_code, 200)

        # Are we presented with a link to the download?
        assert pq(res.content).find('.trigger_download').length
예제 #9
0
    def test_loggedout_notpurchased(self):
        # We don't want any purchases.
        AddonPurchase.objects.all().delete()

        # Make sure we're presented with a log in form.
        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)
        assert pq(r.content).find('#id_username').length

        # Now, let's log in.
        res = self.client.post_ajax(self.url, data=self.data)
        eq_(res.status_code, 200)

        # Make sure we get a link to paypal
        assert pq(res.content).find('.paypal.button').length
예제 #10
0
    def test_my_unlisted_addons(self):
        """I can't see my own unlisted addons on my profile page."""
        eq_(pq(self.client.get(self.url).content)(".num-addons a").length, 0)

        AddonUser.objects.create(user=self.user, addon_id=3615)
        Addon.objects.get(pk=5299).update(is_listed=False)
        AddonUser.objects.create(user=self.user, addon_id=5299)

        r = self.client.get(self.url)
        assert list(r.context["addons"].object_list) == [Addon.objects.get(pk=3615)]

        doc = pq(r.content)
        items = doc("#my-addons .item")
        eq_(items.length, 1)
        eq_(items(".install[data-addon=3615]").length, 1)
예제 #11
0
    def test_loggedout_notpurchased(self):
        # We don't want any purchases.
        AddonPurchase.objects.all().delete()

        # Make sure we're presented with a log in form.
        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)
        assert pq(r.content).find('#id_username').length

        # Now, let's log in.
        res = self.client.post_ajax(self.url, data=self.data)
        eq_(res.status_code, 200)

        # Make sure we get a link to paypal
        assert pq(res.content).find('.paypal.button').length
예제 #12
0
    def test_loggedout_purchased(self):
        # "Buy" the add-on
        self.addon.addonpurchase_set.create(user=self.user.get_profile())

        # Make sure we get a log in field
        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)
        assert pq(r.content).find('#id_username').length

        # Now, let's log in.
        res = self.client.post_ajax(self.url, data=self.data)
        eq_(res.status_code, 200)

        # Are we presented with a link to the download?
        assert pq(res.content).find('.trigger_download').length
예제 #13
0
파일: test_views.py 프로젝트: atsay/zamboni
    def test_email_cant_change(self):
        data = {"username": "******", "email": "*****@*****.**", "display_name": "DJ SurfNTurf"}

        res = self.client.post(self.url, data, follow=True)
        eq_(res.status_code, 200)
        eq_(len(pq(res.content)("div.error")), 1)
        eq_(len(mail.outbox), 0)
예제 #14
0
 def test_my_reviews_pagination(self):
     for i in xrange(20):
         AddonUser.objects.create(user=self.user, addon_id=3615)
     assert len(self.user.addons_listed) > 10, (
         'This user should have way more than 10 add-ons.')
     r = self.client.get(self.url)
     eq_(pq(r.content)('#my-addons .paginator').length, 1)
예제 #15
0
 def test_no_self_abuse(self):
     self.client.login(username='******', password='******')
     r = self.client.get(self.url)
     doc = pq(r.content)
     eq_(doc('#profile-actions #report-user-abuse').length, 0)
     eq_(doc('#popup-staging #report-user-modal.modal').length, 0)
     self.assertTemplateNotUsed(r, 'users/report_abuse.html')
예제 #16
0
 def test_mobile_login_apps_preview(self):
     r = self.client.get(self.url)
     eq_(r.status_code, 200)
     doc = pq(r.content)('header')
     eq_(doc('nav').length, 1)
     eq_(doc('#home').length, 0)
     eq_(doc('#auth-nav li.login').length, 0)
예제 #17
0
 def test_no_my_collections(self):
     Collection.objects.filter(author=self.user).delete()
     r = self.client.get(self.url)
     self.assertTemplateNotUsed(r, 'bandwagon/users/collection_list.html')
     doc = pq(r.content)
     eq_(doc('#my-collections').length, 0)
     eq_(doc('#reviews.full').length, 1)
예제 #18
0
 def test_my_reviews_pagination(self):
     for i in xrange(20):
         AddonUser.objects.create(user=self.user, addon_id=3615)
     assert len(self.user.addons_listed) > 10, (
         'This user should have way more than 10 add-ons.')
     r = self.client.get(self.url)
     eq_(pq(r.content)('#my-addons .paginator').length, 1)
예제 #19
0
    def test_correct_url_update_notification(self):
        # Make sure the user is subscribed
        perm_setting = email.NOTIFICATIONS[0]
        un = UserNotification.objects.create(notification_id=perm_setting.id,
                                             user=self.user_profile,
                                             enabled=True)

        # Create a URL
        token, hash = UnsubscribeCode.create(self.user.email)
        url = reverse('users.unsubscribe', args=[token, hash,
                                                 perm_setting.short])

        # Load the URL
        r = self.client.get(url)
        doc = pq(r.content)

        # Check that it was successful
        assert doc('#unsubscribe-success').length
        assert doc('#standalone').length
        eq_(doc('#standalone ul li').length, 1)

        # Make sure the user is unsubscribed
        un = UserNotification.objects.filter(notification_id=perm_setting.id,
                                             user=self.user)
        eq_(un.count(), 1)
        eq_(un.all()[0].enabled, False)
예제 #20
0
    def test_my_addons(self):
        eq_(pq(self.client.get(self.url).content)(".num-addons a").length, 0)

        AddonUser.objects.create(user=self.user, addon_id=3615)
        AddonUser.objects.create(user=self.user, addon_id=5299)

        r = self.client.get(self.url)
        a = r.context["addons"].object_list
        eq_(list(a), sorted(a, key=lambda x: x.weekly_downloads, reverse=True))

        doc = pq(r.content)
        eq_(doc('.num-addons a[href="#my-submissions"]').length, 1)
        items = doc("#my-addons .item")
        eq_(items.length, 2)
        eq_(items(".install[data-addon=3615]").length, 1)
        eq_(items(".install[data-addon=5299]").length, 1)
예제 #21
0
 def test_collections_toggles(self):
     r = self.client.get(self.url)
     eq_(r.status_code, 200)
     doc = pq(r.content)
     eq_(
         doc('#profile-misc').length, 1,
         'Collections options should be visible.')
예제 #22
0
 def test_mobile_login(self):
     r = self.client.get(self.url)
     eq_(r.status_code, 200)
     doc = pq(r.content)("header")
     eq_(doc("nav").length, 1)
     eq_(doc("#home").length, 1)
     eq_(doc("#auth-nav li.login").length, 0)
예제 #23
0
 def test_no_self_abuse(self):
     self.client.login(username="******", password="******")
     r = self.client.get(self.url)
     doc = pq(r.content)
     eq_(doc("#profile-actions #report-user-abuse").length, 0)
     eq_(doc("#popup-staging #report-user-modal.modal").length, 0)
     self.assertTemplateNotUsed(r, "users/report_abuse.html")
예제 #24
0
 def test_mobile_login_apps_preview(self):
     r = self.client.get(self.url)
     eq_(r.status_code, 200)
     doc = pq(r.content)('header')
     eq_(doc('nav').length, 1)
     eq_(doc('#home').length, 0)
     eq_(doc('#auth-nav li.login').length, 0)
예제 #25
0
    def test_my_addons(self):
        eq_(pq(self.client.get(self.url).content)('.num-addons a').length, 0)

        AddonUser.objects.create(user=self.user, addon_id=3615)
        AddonUser.objects.create(user=self.user, addon_id=5299)

        r = self.client.get(self.url)
        a = r.context['addons'].object_list
        eq_(list(a), sorted(a, key=lambda x: x.weekly_downloads, reverse=True))

        doc = pq(r.content)
        eq_(doc('.num-addons a[href="#my-submissions"]').length, 1)
        items = doc('#my-addons .item')
        eq_(items.length, 2)
        eq_(items('.install[data-addon=3615]').length, 1)
        eq_(items('.install[data-addon=5299]').length, 1)
예제 #26
0
 def test_no_my_collections(self):
     Collection.objects.filter(author=self.user).delete()
     r = self.client.get(self.url)
     self.assertTemplateNotUsed(r, "bandwagon/users/collection_list.html")
     doc = pq(r.content)
     eq_(doc("#my-collections").length, 0)
     eq_(doc("#reviews.full").length, 1)
예제 #27
0
    def test_my_unlisted_addons(self):
        """I can't see my own unlisted addons on my profile page."""
        eq_(pq(self.client.get(self.url).content)('.num-addons a').length, 0)

        AddonUser.objects.create(user=self.user, addon_id=3615)
        Addon.objects.get(pk=5299).update(is_listed=False)
        AddonUser.objects.create(user=self.user, addon_id=5299)

        r = self.client.get(self.url)
        assert list(
            r.context['addons'].object_list) == [Addon.objects.get(pk=3615)]

        doc = pq(r.content)
        items = doc('#my-addons .item')
        eq_(items.length, 1)
        eq_(items('.install[data-addon=3615]').length, 1)
예제 #28
0
    def test_correct_url_update_notification(self):
        # Make sure the user is subscribed
        perm_setting = email.NOTIFICATIONS[0]
        un = UserNotification.objects.create(notification_id=perm_setting.id,
                                             user=self.user_profile,
                                             enabled=True)

        # Create a URL
        token, hash = UnsubscribeCode.create(self.user.email)
        url = reverse('users.unsubscribe', args=[token, hash,
                                                 perm_setting.short])

        # Load the URL
        r = self.client.get(url)
        doc = pq(r.content)

        # Check that it was successful
        assert doc('#unsubscribe-success').length
        assert doc('#standalone').length
        eq_(doc('#standalone ul li').length, 1)

        # Make sure the user is unsubscribed
        un = UserNotification.objects.filter(notification_id=perm_setting.id,
                                             user=self.user)
        eq_(un.count(), 1)
        eq_(un.all()[0].enabled, False)
예제 #29
0
    def test_not_my_unlisted_addons(self):
        """I can't see others' unlisted addons on their profile pages."""
        res = self.client.get("/user/999/", follow=True)
        eq_(pq(res.content)(".num-addons a").length, 0)

        user = UserProfile.objects.get(pk=999)
        AddonUser.objects.create(user=user, addon_id=3615)
        Addon.objects.get(pk=5299).update(is_listed=False)
        AddonUser.objects.create(user=user, addon_id=5299)

        r = self.client.get("/user/999/", follow=True)
        assert list(r.context["addons"].object_list) == [Addon.objects.get(pk=3615)]

        doc = pq(r.content)
        items = doc("#my-addons .item")
        eq_(items.length, 1)
        eq_(items(".install[data-addon=3615]").length, 1)
예제 #30
0
 def test_my_last_login_authenticated(self):
     self.user.update(last_login_ip='255.255.255.255')
     self.login(self.user)
     res = self.client.get(self.url)
     eq_(res.status_code, 200)
     doc = pq(res.content)
     assert doc('.last-login-time td').text()
     eq_(doc('.last-login-ip td').text(), '255.255.255.255')
예제 #31
0
 def test_my_last_login_authenticated(self):
     self.user.update(last_login_ip="255.255.255.255")
     self.login(self.user)
     res = self.client.get(self.url)
     eq_(res.status_code, 200)
     doc = pq(res.content)
     assert doc(".last-login-time td").text()
     eq_(doc(".last-login-ip td").text(), "255.255.255.255")
예제 #32
0
    def test_email_cant_change(self):
        data = {'username': '******',
                'email': '*****@*****.**',
                'display_name': 'DJ SurfNTurf', }

        res = self.client.post(self.url, data, follow=True)
        eq_(res.status_code, 200)
        eq_(len(pq(res.content)('div.error')), 1)
        eq_(len(mail.outbox), 0)
예제 #33
0
    def test_confirm_resend(self):
        # User doesn't have a confirmation code
        url = reverse('users.confirm.resend', args=[self.user.id])
        r = self.client.get(url, follow=True)
        anon = pq(r.content)('body').attr('data-anonymous')
        self.assertTrue(anon)

        self.user_profile.confirmationcode = "code"
        self.user_profile.save()
예제 #34
0
    def test_email_cant_change(self):
        data = {'username': '******',
                'email': '*****@*****.**',
                'display_name': 'DJ SurfNTurf', }

        res = self.client.post(self.url, data, follow=True)
        eq_(res.status_code, 200)
        eq_(len(pq(res.content)('div.error')), 1)
        eq_(len(mail.outbox), 0)
예제 #35
0
    def test_not_my_unlisted_addons(self):
        """I can't see others' unlisted addons on their profile pages."""
        res = self.client.get('/user/999/', follow=True)
        eq_(pq(res.content)('.num-addons a').length, 0)

        user = UserProfile.objects.get(pk=999)
        AddonUser.objects.create(user=user, addon_id=3615)
        Addon.objects.get(pk=5299).update(is_listed=False)
        AddonUser.objects.create(user=user, addon_id=5299)

        r = self.client.get('/user/999/', follow=True)
        assert list(
            r.context['addons'].object_list) == [Addon.objects.get(pk=3615)]

        doc = pq(r.content)
        items = doc('#my-addons .item')
        eq_(items.length, 1)
        eq_(items('.install[data-addon=3615]').length, 1)
예제 #36
0
    def test_loggedin_notpurchased(self):
        # No purchases; logged in.
        AddonPurchase.objects.all().delete()
        assert self.client.login(**self.data)

        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)

        # Make sure we get a link to paypal.
        assert pq(r.content).find('.paypal.button').length
예제 #37
0
    def test_wrong_url(self):
        perm_setting = email.NOTIFICATIONS[0]
        token, hash = UnsubscribeCode.create(self.user.email)
        hash = hash[::-1]  # Reverse the hash, so it's wrong

        url = reverse("users.unsubscribe", args=[token, hash, perm_setting.short])
        r = self.client.get(url)
        doc = pq(r.content)

        eq_(doc("#unsubscribe-fail").length, 1)
예제 #38
0
    def test_loggedin_notpurchased(self):
        # No purchases; logged in.
        AddonPurchase.objects.all().delete()
        assert self.client.login(**self.data)

        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)

        # Make sure we get a link to paypal.
        assert pq(r.content).find('.paypal.button').length
예제 #39
0
    def test_abuse_logged_in(self):
        self.client.login(username="******", password="******")
        self.client.post(self.full_page, {"text": "spammy"})
        eq_(len(mail.outbox), 1)
        assert "spammy" in mail.outbox[0].body
        report = AbuseReport.objects.get(user=10482)
        eq_(report.message, "spammy")
        eq_(report.reporter.email, "*****@*****.**")

        r = self.client.get(self.full_page)
        eq_(pq(r.content)(".notification-box h2").length, 1)
예제 #40
0
    def test_wrong_url(self):
        perm_setting = email.NOTIFICATIONS[0]
        token, hash = UnsubscribeCode.create(self.user.email)
        hash = hash[::-1]  # Reverse the hash, so it's wrong

        url = reverse('users.unsubscribe', args=[token, hash,
                                                 perm_setting.short])
        r = self.client.get(url)
        doc = pq(r.content)

        eq_(doc('#unsubscribe-fail').length, 1)
예제 #41
0
    def test_abuse_logged_in(self):
        self.client.login(username='******', password='******')
        self.client.post(self.full_page, {'text': 'spammy'})
        eq_(len(mail.outbox), 1)
        assert 'spammy' in mail.outbox[0].body
        report = AbuseReport.objects.get(user=10482)
        eq_(report.message, 'spammy')
        eq_(report.reporter.email, '*****@*****.**')

        r = self.client.get(self.full_page)
        eq_(pq(r.content)('.notification-box h2').length, 1)
예제 #42
0
    def test_abuse_logged_in(self):
        self.client.login(username='******', password='******')
        self.client.post(self.full_page, {'text': 'spammy'})
        eq_(len(mail.outbox), 1)
        assert 'spammy' in mail.outbox[0].body
        report = AbuseReport.objects.get(user=10482)
        eq_(report.message, 'spammy')
        eq_(report.reporter.email, '*****@*****.**')

        r = self.client.get(self.full_page)
        eq_(pq(r.content)('.notification-box h2').length, 1)
예제 #43
0
    def test_loggedin_purchased(self):
        # Log the user in
        assert self.client.login(**self.data)

        # "Buy" the add-on
        self.addon.addonpurchase_set.create(user=self.user.get_profile())

        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)

        # This only happens if we've bought it.
        assert pq(r.content).find('.trigger_download').length
예제 #44
0
 def test_user_abuse_form(self):
     abuse_url = reverse('users.abuse', args=[self.user.id])
     r = self.client.get(self.url)
     doc = pq(r.content)
     button = doc('#profile-actions #report-user-abuse')
     eq_(button.length, 1)
     eq_(button.attr('href'), abuse_url)
     modal = doc('#popup-staging #report-user-modal.modal')
     eq_(modal.length, 1)
     eq_(modal('form').attr('action'), abuse_url)
     eq_(modal('textarea[name=text]').length, 1)
     self.assertTemplateUsed(r, 'users/report_abuse.html')
예제 #45
0
    def _test_good(self, res):
        eq_(res.status_code, 200)

        ids = res.context['addons'].object_list.values_list('id', flat=True)
        self.assertSetEqual(ids, [self.theme.id])

        doc = pq(res.content)
        eq_(doc('.no-results').length, 0)

        results = doc('.personas-grid .persona-preview')
        eq_(results.length, 1)
        eq_(results.find('h6').text(), unicode(self.theme.name))
예제 #46
0
    def _test_good(self, res):
        eq_(res.status_code, 200)

        ids = res.context['addons'].object_list.values_list('id', flat=True)
        self.assertSetEqual(ids, [self.theme.id])

        doc = pq(res.content)
        eq_(doc('.no-results').length, 0)

        results = doc('.personas-grid .persona-preview')
        eq_(results.length, 1)
        eq_(results.find('h6').text(), unicode(self.theme.name))
예제 #47
0
    def test_loggedin_purchased(self):
        # Log the user in
        assert self.client.login(**self.data)

        # "Buy" the add-on
        self.addon.addonpurchase_set.create(user=self.user.get_profile())

        r = self.client.get_ajax(self.url)
        eq_(r.status_code, 200)

        # This only happens if we've bought it.
        assert pq(r.content).find('.trigger_download').length
예제 #48
0
    def _test_good(self, res):
        eq_(res.status_code, 200)

        ids = res.context["addons"].object_list.values_list("id", flat=True)
        self.assertSetEqual(ids, [self.theme.id])

        doc = pq(res.content)
        eq_(doc(".no-results").length, 0)

        results = doc(".personas-grid .persona-preview")
        eq_(results.length, 1)
        eq_(results.find("h6").text(), unicode(self.theme.name))
예제 #49
0
 def test_user_abuse_form(self):
     abuse_url = reverse("users.abuse", args=[self.user.id])
     r = self.client.get(self.url)
     doc = pq(r.content)
     button = doc("#profile-actions #report-user-abuse")
     eq_(button.length, 1)
     eq_(button.attr("href"), abuse_url)
     modal = doc("#popup-staging #report-user-modal.modal")
     eq_(modal.length, 1)
     eq_(modal("form").attr("action"), abuse_url)
     eq_(modal("textarea[name=text]").length, 1)
     self.assertTemplateUsed(r, "users/report_abuse.html")
예제 #50
0
 def test_user_abuse_form(self):
     abuse_url = reverse('users.abuse', args=[self.user.id])
     r = self.client.get(self.url)
     doc = pq(r.content)
     button = doc('#profile-actions #report-user-abuse')
     eq_(button.length, 1)
     eq_(button.attr('href'), abuse_url)
     modal = doc('#popup-staging #report-user-modal.modal')
     eq_(modal.length, 1)
     eq_(modal('form').attr('action'), abuse_url)
     eq_(modal('textarea[name=text]').length, 1)
     self.assertTemplateUsed(r, 'users/report_abuse.html')
예제 #51
0
 def check_default_choices(self, choices, checked=True):
     doc = pq(self.client.get(self.url).content)
     eq_(doc("input[name=notifications]:checkbox").length, len(choices))
     for id, label in choices:
         box = doc("input[name=notifications][value=%s]" % id)
         if checked:
             eq_(box.filter(":checked").length, 1)
         else:
             eq_(box.length, 1)
         parent = box.parent("label")
         if checked:
             eq_(parent.find(".msg").length, 1)  # Check for "NEW" message.
         eq_(parent.remove(".msg, .req").text(), label)
예제 #52
0
 def check_default_choices(self, choices, checked=True):
     doc = pq(self.client.get(self.url).content)
     eq_(doc('input[name=notifications]:checkbox').length, len(choices))
     for id, label in choices:
         box = doc('input[name=notifications][value=%s]' % id)
         if checked:
             eq_(box.filter(':checked').length, 1)
         else:
             eq_(box.length, 1)
         parent = box.parent('label')
         if checked:
             eq_(parent.find('.msg').length, 1)  # Check for "NEW" message.
         eq_(parent.remove('.msg, .req').text(), label)
예제 #53
0
    def test_confirm_resend(self):
        # User doesn't have a confirmation code
        url = reverse('users.confirm.resend', args=[self.user.id])
        r = self.client.get(url, follow=True)
        anon = pq(r.content)('body').attr('data-anonymous')
        self.assertTrue(anon)

        self.user_profile.confirmationcode = "code"
        self.user_profile.save()

        # URL has the wrong confirmation code
        url = reverse('users.confirm.resend', args=[self.user.id])
        r = self.client.get(url, follow=True)
        self.assertContains(r, 'An email has been sent to your address')
예제 #54
0
    def test_my_reviews(self):
        r = Review.objects.filter(reply_to=None)[0]
        r.update(user=self.user)
        cache.clear()
        self.assertSetEqual(self.user.reviews, [r])

        r = self.client.get(self.url)
        doc = pq(r.content)('#reviews')
        assert not doc.hasClass('full'), (
            'reviews should not have "full" class when there are collections')
        eq_(doc('.item').length, 1)
        eq_(doc('#review-218207').length, 1)

        # Edit Review form should be present.
        self.assertTemplateUsed(r, 'reviews/edit_review.html')
예제 #55
0
    def test_new_confirm(self):
        # User doesn't have a confirmation code.
        url = reverse('users.confirm', args=[self.user.id, 'code'])
        r = self.client.get(url, follow=True)
        is_anonymous = pq(r.content)('body').attr('data-anonymous')
        eq_(json.loads(is_anonymous), True)

        self.user_profile.update(confirmationcode='code')

        # URL has the wrong confirmation code.
        url = reverse('users.confirm', args=[self.user.id, 'blah'])
        r = self.client.get(url, follow=True)
        self.assertContains(r, 'Invalid confirmation code!')

        # URL has the right confirmation code.
        url = reverse('users.confirm', args=[self.user.id, 'code'])
        r = self.client.get(url, follow=True)
        self.assertContains(r, 'Successfully verified!')
예제 #56
0
    def test_confirm(self):
        # User doesn't have a confirmation code
        url = reverse('users.confirm', args=[self.user.id, 'code'])
        r = self.client.get(url, follow=True)
        anon = pq(r.content)('body').attr('data-anonymous')
        self.assertTrue(anon)

        self.user_profile.confirmationcode = "code"
        self.user_profile.save()

        # URL has the wrong confirmation code
        url = reverse('users.confirm', args=[self.user.id, 'blah'])
        r = self.client.get(url, follow=True)
        self.assertContains(r, 'Invalid confirmation code!')

        # URL has the right confirmation code
        url = reverse('users.confirm', args=[self.user.id, 'code'])
        r = self.client.get(url, follow=True)
        self.assertContains(r, 'Successfully verified!')
예제 #57
0
    def test_my_collections_created(self):
        coll = Collection.objects.listed().filter(author=self.user)
        eq_(len(coll), 1)

        r = self.client.get(self.url)
        self.assertTemplateUsed(r, 'bandwagon/users/collection_list.html')
        self.assertSetEqual(r.context['own_coll'], coll)

        doc = pq(r.content)
        eq_(doc('#reviews.full').length, 0)
        ul = doc('#my-collections #my-created')
        eq_(ul.length, 1)

        li = ul.find('li')
        eq_(li.length, 1)

        a = li.find('a')
        eq_(a.attr('href'), coll[0].get_url_path())
        eq_(a.text(), unicode(coll[0].name))
예제 #58
0
    def test_my_collections_followed(self):
        coll = Collection.objects.all()[0]
        CollectionWatcher.objects.create(collection=coll, user=self.user)
        mine = Collection.objects.listed().filter(following__user=self.user)
        eq_(list(mine), [coll])

        r = self.client.get(self.url)
        self.assertTemplateUsed(r, 'bandwagon/users/collection_list.html')
        eq_(list(r.context['fav_coll']), [coll])

        doc = pq(r.content)
        eq_(doc('#reviews.full').length, 0)
        ul = doc('#my-collections #my-favorite')
        eq_(ul.length, 1)

        li = ul.find('li')
        eq_(li.length, 1)

        a = li.find('a')
        eq_(a.attr('href'), coll.get_url_path())
        eq_(a.text(), unicode(coll.name))
예제 #59
0
    def test_edit_notifications(self):
        post = self.correct.copy()
        post['notifications'] = [2, 4, 6]

        # Make jbalogh a developer
        addon = Addon.objects.create(type=amo.ADDON_EXTENSION)
        AddonUser.objects.create(user=self.user, addon=addon)

        res = self.client.post(self.url, post)
        eq_(res.status_code, 302)

        mandatory = [n.id for n in email.NOTIFICATIONS if n.mandatory]
        total = len(post['notifications'] + mandatory)
        eq_(UserNotification.objects.count(), len(email.NOTIFICATION))
        eq_(UserNotification.objects.filter(enabled=True).count(), total)

        res = self.client.get(self.url, post)
        doc = pq(res.content)
        eq_(doc('[name=notifications]:checked').length, total)

        eq_(doc('.more-none').length, len(email.NOTIFICATION_GROUPS))
        eq_(doc('.more-all').length, len(email.NOTIFICATION_GROUPS))
예제 #60
0
    def test_edit_notifications(self):
        # Make jbalogh a developer.
        AddonUser.objects.create(user=self.user,
            addon=Addon.objects.create(type=amo.ADDON_EXTENSION))

        choices = email.NOTIFICATIONS_CHOICES
        self.check_default_choices(choices)

        self.data['notifications'] = [2, 4, 6]
        r = self.client.post(self.url, self.data)
        self.assertRedirects(r, self.url, 302)

        mandatory = [n.id for n in email.NOTIFICATIONS if n.mandatory]
        total = len(self.data['notifications'] + mandatory)
        eq_(UserNotification.objects.count(), len(email.NOTIFICATIONS))
        eq_(UserNotification.objects.filter(enabled=True).count(), total)

        doc = pq(self.client.get(self.url, self.data).content)
        eq_(doc('input[name=notifications]:checked').length, total)

        eq_(doc('.more-none').length, len(email.NOTIFICATION_GROUPS))
        eq_(doc('.more-all').length, len(email.NOTIFICATION_GROUPS))