Exemple #1
0
    def test_activate_locale(self):
        eq_(translation.get_language(), 'en-us')
        with UserProfile(username='******').activate_lang():
            eq_(translation.get_language(), 'en-us')

        with UserProfile(username='******', lang='fr').activate_lang():
            eq_(translation.get_language(), 'fr')
Exemple #2
0
 def test_get_points(self):
     reviewer = UserProfile()
     self.review.passed = True
     self.review.reviewer = reviewer
     ok_(not self.award_additional_review_points.called)
     self.review.execute_post_review_task()
     self.award_additional_review_points.assert_called_with(
         reviewer, self.app, QUEUE_TARAKO)
Exemple #3
0
 def get_object(self, *args, **kwargs):
     try:
         user = super(AnonymousUserMixin, self).get_object(*args, **kwargs)
     except http.Http404:
         # The base get_object() will raise Http404 instead of DoesNotExist.
         # Treat no object as an anonymous user (source: unknown).
         user = UserProfile(is_verified=False)
     return user
Exemple #4
0
 def test_log_reviewer_action_blank_comment_when_none(self):
     reviewer = UserProfile()
     self.review.passed = True
     self.review.comment = None
     self.review.reviewer = reviewer
     ok_(not self.log_reviewer_action.called)
     self.review.execute_post_review_task()
     self.log_reviewer_action.assert_called_with(
         self.app, reviewer, '', amo.LOG.PASS_ADDITIONAL_REVIEW,
         queue=QUEUE_TARAKO)
Exemple #5
0
 def test_log_reviewer_action_when_failed(self):
     reviewer = UserProfile()
     comment = 'It would not start'
     self.review.passed = False
     self.review.comment = comment
     self.review.reviewer = reviewer
     ok_(not self.log_reviewer_action.called)
     self.review.execute_post_review_task()
     self.log_reviewer_action.assert_called_with(
         self.app, reviewer, comment, amo.LOG.FAIL_ADDITIONAL_REVIEW,
         queue=QUEUE_TARAKO)
Exemple #6
0
 def test_log_reviewer_action_when_passed(self):
     reviewer = UserProfile()
     comment = 'It is totally awesome'
     self.review.passed = True
     self.review.comment = comment
     self.review.reviewer = reviewer
     ok_(not self.log_reviewer_action.called)
     self.review.execute_post_review_task()
     self.log_reviewer_action.assert_called_with(
         self.app, reviewer, comment, amo.LOG.PASS_ADDITIONAL_REVIEW,
         queue=QUEUE_TARAKO)
Exemple #7
0
class TestDevAgreement(mkt.site.tests.TestCase):

    def setUp(self):
        self.user = UserProfile()
        self.days = lambda x: self.days_ago(x).date()

    def test_none(self):
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=None):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_date_oops(self):
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=('wat?')):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_not_agreed(self):
        # The user has never agreed to it so in this case we don't need to
        # worry them about changes.
        self.user.update(read_dev_agreement=None)
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=self.days(10)):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_past_agreed(self):
        self.user.update(read_dev_agreement=self.days_ago(10))
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=self.days(5)):
            eq_(helpers.dev_agreement_ok(self.user), False)

    def test_not_past(self):
        self.user.update(read_dev_agreement=self.days_ago(5))
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=self.days(10)):
            eq_(helpers.dev_agreement_ok(self.user), True)
Exemple #8
0
class TestDevAgreement(amo.tests.TestCase):

    def setUp(self):
        self.user = UserProfile()

    def test_none(self):
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=None):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_date_oops(self):
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=('wat?')):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_not_agreed(self):
        # The user has never agreed to it so in this case we don't need to
        # worry them about changes.
        self.user.update(read_dev_agreement=None)
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=
                           self.days_ago(10).date()):
            eq_(helpers.dev_agreement_ok(self.user), True)

    def test_past_agreed(self):
        self.user.update(read_dev_agreement=self.days_ago(10))
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=self.days_ago(5).date()):
            eq_(helpers.dev_agreement_ok(self.user), False)

    def test_not_past(self):
        self.user.update(read_dev_agreement=self.days_ago(5))
        with self.settings(DEV_AGREEMENT_LAST_UPDATED=
                           self.days_ago(10).date()):
            eq_(helpers.dev_agreement_ok(self.user), True)
Exemple #9
0
def app_data(app):
    """App data that IARC needs in PushCert response / AttachToCert request."""
    author = app.listed_authors[0] if app.listed_authors else UserProfile()
    with no_translation(app.default_locale):
        app_name = unicode(Webapp.with_deleted.get(pk=app.pk).name)
    data = {
        'Publish': app.is_public(),
        'ProductName': app_name,
        'StoreProductID': app.guid,
        'StoreProductURL': absolutify(app.get_url_path()),
        # We want an identifier that does not change when users attached to
        # an app are shuffled around, so just use the app PK as developer id.
        'StoreDeveloperID': app.pk,
        # PushCert and AttachToCert docs use a different property for the
        # developer email address, use both just in case.
        'DeveloperEmail': author.email,
        'EmailAddress': author.email,
        'CompanyName': app.developer_name,
    }
    return data
 def setUp(self):
     self.permission = AllowNone()
     self.anonymous = AnonymousUser()
     self.user = UserProfile()
     self.request = RequestFactory().get('/')
     self.request.user = self.anonymous
Exemple #11
0
 def setUp(self):
     self.user = UserProfile()
     self.days = lambda x: self.days_ago(x).date()
Exemple #12
0
 def setUp(self):
     self.account = UserProfile()
Exemple #13
0
 def setUp(self):
     self.user = UserProfile()
Exemple #14
0
def test_user_data():
    u = user_data(UserProfile(username='******', pk=1))
    eq_(u['anonymous'], False)
 def setUp(self):
     self.user = UserProfile()
     self.days = lambda x: self.days_ago(x).date()
Exemple #16
0
def test_user_data():
    u = user_data(UserProfile(pk=1))
    eq_(u['anonymous'], False)