示例#1
0
    def setUp(self):
        super(TestSearchView, self).setUp()
        # Set up some sample data
        # 4 happy, 3 sad.
        # 2 Windows XP, 2 Linux, 1 OS X, 2 Windows 7
        now = datetime.now()
        # The dashboard by default shows the last week of data, so
        # these need to be relative to today. The alternative is that
        # every test gives an explicit date range, and that is
        # annoying and verbose.
        items = [
            # happy, platform, locale, description, created
            (True, '', 'en-US', 'apple', now - timedelta(days=6)),
            (True, 'Windows 7', 'es', 'banana', now - timedelta(days=5)),
            (True, 'Linux', 'en-US', 'orange', now - timedelta(days=4)),
            (True, 'Linux', 'en-US', 'apple', now - timedelta(days=3)),
            (False, 'Windows XP', 'en-US', 'banana', now - timedelta(days=2)),
            (False, 'Windows 7', 'en-US', 'orange', now - timedelta(days=1)),
            (False, 'Linux', 'es', u'\u2713 apple', now - timedelta(days=0)),
        ]
        for happy, platform, locale, description, created in items:
            # We don't need to keep this around, just need to create it.
            response(happy=happy, platform=platform, locale=locale,
                     description=description, created=created, save=True)

        self.refresh()

        # Create analyzer and log analyzer in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
示例#2
0
    def setUp(self):
        super(TestOccurrencesReportView, self).setUp()
        # Set up some sample data
        items = [
            # happy, locale, description
            (True, 'en-US', 'apple banana orange pear'),
            (True, 'en-US', 'orange pear kiwi'),
            (True, 'en-US', 'chocolate chocolate yum'),
            (False, 'en-US', 'apple banana grapefruit'),

            # This one doesn't create bigrams because there isn't enough words
            (False, 'en-US', 'orange'),

            # This one shouldn't show up
            (False, 'es', 'apple banana'),
        ]
        for happy, locale, description in items:
            response(
                happy=happy, locale=locale, description=description, save=True)

        self.refresh()

        # Create analyzer and log analyzer in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
示例#3
0
    def setUp(self):
        super(TestOccurrencesView, self).setUp()
        # Set up some sample data
        items = [
            # happy, locale, description
            (True, 'en-US', 'apple banana orange pear'),
            (True, 'en-US', 'orange pear kiwi'),
            (True, 'en-US', 'chocolate chocolate yum'),
            (False, 'en-US', 'apple banana grapefruit'),

            # This one doesn't create bigrams because there isn't enough words
            (False, 'en-US', 'orange'),

            # This one shouldn't show up
            (False, 'es', 'apple banana'),
        ]
        for happy, locale, description in items:
            response(
                happy=happy, locale=locale, description=description, save=True)

        self.refresh()

        # Create analyzer and log analyzer in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
示例#4
0
    def setUp(self):
        super(TestSearchView, self).setUp()
        # Set up some sample data
        # 4 happy, 3 sad.
        # 2 Windows XP, 2 Linux, 1 OS X, 2 Windows 7
        now = datetime.now()
        # The dashboard by default shows the last week of data, so
        # these need to be relative to today. The alternative is that
        # every test gives an explicit date range, and that is
        # annoying and verbose.
        items = [
            # happy, platform, locale, description, created
            (True, '', 'en-US', 'apple', now - timedelta(days=6)),
            (True, 'Windows 7', 'es', 'banana', now - timedelta(days=5)),
            (True, 'Linux', 'en-US', 'orange', now - timedelta(days=4)),
            (True, 'Linux', 'en-US', 'apple', now - timedelta(days=3)),
            (False, 'Windows XP', 'en-US', 'banana', now - timedelta(days=2)),
            (False, 'Windows 7', 'en-US', 'orange', now - timedelta(days=1)),
            (False, 'Linux', 'es', u'\u2713 apple', now - timedelta(days=0)),
        ]
        for happy, platform, locale, description, created in items:
            # We don't need to keep this around, just need to create it.
            response(happy=happy, platform=platform, locale=locale,
                     description=description, created=created, save=True)

        self.refresh()

        # Create analyzer and log analyzer in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
示例#5
0
    def test_existing_user(self):
        """Tests that existing users get redirected to right place"""
        # Create a user that has no profile--this is the sign that the
        # user is new!
        new_user = user(save=True)
        profile(user=new_user, save=True)
        self.client_login_user(new_user)

        # Now do some ridiculous setup so we can call login_success()
        # on the Verify and see if it did what it should be doing.

        # FIXME - this can go away post django-browserid 0.9
        new_user.backend = 'django_browserid.auth.BrowserIDBackend'

        # First, do it RAW!
        get_request = RequestFactory().get(reverse('dashboard'))
        get_request.user = new_user
        get_request.session = self.client.session

        fv = FjordVerify()
        fv.user = new_user
        fv.request = get_request

        resp = fv.login_success()
        eq_(302, resp.status_code)
        eq_(resp.get('location'), '/')

        # Now do it with next!
        get_request = RequestFactory().get(reverse('dashboard') + '?next=/foo')
        get_request.user = new_user
        get_request.session = self.client.session

        fv = FjordVerify()
        fv.user = new_user
        fv.request = get_request

        resp = fv.login_success()
        eq_(302, resp.status_code)
        eq_(resp.get('location'), '/foo')
示例#6
0
    def test_response_view_analyzer(self):
        """Test secret section only shows up for analyzers"""
        resp = response(happy=True,
                        description=u'the bestest best!',
                        save=True)

        self.refresh()
        r = self.client.get(reverse('response_view', args=(resp.id, )))

        eq_(200, r.status_code)
        self.assertTemplateUsed(r, 'analytics/response.html')
        assert str(resp.description) in r.content

        # Verify there is no secret area visible for non-analyzers.
        pq = PyQuery(r.content)
        secretarea = pq('dl.secret')
        eq_(len(secretarea), 0)

        # Create an analyzer and log her in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
        r = self.client.get(reverse('response_view', args=(resp.id, )))

        eq_(200, r.status_code)
        self.assertTemplateUsed(r, 'analytics/response.html')
        assert str(resp.description) in r.content

        # Verify the secret area is there.
        pq = PyQuery(r.content)
        secretarea = pq('dl.secret')
        eq_(len(secretarea), 1)

        # Verify there is an mlt section in the secret area.
        mlt = pq('dd#mlt')
        eq_(len(mlt), 1)
示例#7
0
    def test_permissions(self):
        # Verifies that only analyzers can see the spam dashboard link
        resp = self.client.get(reverse('dashboard'))
        eq_(200, resp.status_code)
        assert 'sdashboard' not in resp.content

        # Verifies that only analyzers can see the spam dashboard
        resp = self.client.get(reverse('spam_dashboard'))
        eq_(403, resp.status_code)

        # Verify analyzers can see spam dashboard link
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
        resp = self.client.get(reverse('dashboard'))
        eq_(200, resp.status_code)
        assert 'sdashboard' in resp.content

        # Verify analyzers can see spam dashboard
        resp = self.client.get(reverse('spam_dashboard'))
        eq_(200, resp.status_code)
示例#8
0
    def test_response_view_analyzer(self):
        """Test secret section only shows up for analyzers"""
        resp = response(happy=True, description=u'the bestest best!',
                        save=True)

        self.refresh()
        r = self.client.get(reverse('response_view', args=(resp.id,)))

        eq_(200, r.status_code)
        self.assertTemplateUsed(r, 'analytics/response.html')
        assert str(resp.description) in r.content

        # Verify there is no secret area visible for non-analyzers.
        pq = PyQuery(r.content)
        secretarea = pq('dl.secret')
        eq_(len(secretarea), 0)

        # Create an analyzer and log her in
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
        r = self.client.get(reverse('response_view', args=(resp.id,)))

        eq_(200, r.status_code)
        self.assertTemplateUsed(r, 'analytics/response.html')
        assert str(resp.description) in r.content

        # Verify the secret area is there.
        pq = PyQuery(r.content)
        secretarea = pq('dl.secret')
        eq_(len(secretarea), 1)

        # Verify there is an mlt section in the secret area.
        mlt = pq('dd#mlt')
        eq_(len(mlt), 1)
示例#9
0
    def test_permissions(self):
        # Verifies that only analyzers can see the analytics dashboard
        # link
        resp = self.client.get(reverse('dashboard'))
        eq_(200, resp.status_code)
        assert 'adashboard' not in resp.content

        # Verifies that only analyzers can see the analytics dashboard
        resp = self.client.get(reverse('analytics_dashboard'))
        eq_(403, resp.status_code)

        # Verify analyzers can see analytics dashboard link
        jane = user(email='*****@*****.**', save=True)
        profile(user=jane, save=True)
        jane.groups.add(Group.objects.get(name='analyzers'))

        self.client_login_user(jane)
        resp = self.client.get(reverse('dashboard'))
        eq_(200, resp.status_code)
        assert 'adashboard' in resp.content

        # Verify analyzers can see analytics dashboard
        resp = self.client.get(reverse('analytics_dashboard'))
        eq_(200, resp.status_code)
示例#10
0
 def setUp(self):
     super(TestNewUserView, self).setUp()
     jane = user(email='*****@*****.**', save=True)
     profile(user=jane, save=True)
     jane.groups.add(Group.objects.get(name='analyzers'))
     self.jane = jane
示例#11
0
 def setUp(self):
     super(TestNewUserView, self).setUp()
     jane = user(email='*****@*****.**', save=True)
     profile(user=jane, save=True)
     jane.groups.add(Group.objects.get(name='analyzers'))
     self.jane = jane