Exemple #1
0
 def _http_verb(cls, verb, path, client=None, data=None, user=None, password=None, https=False, **kwargs):
     data = data or {}
     client = client or cls.get_client(user=user, password=password)
     kwargs['HTTP_X_FORWARDED_PROTO'] = 'https' if https else 'http' # Simulates ELB
     response = getattr(client, verb.lower())(path, data=data, **kwargs)
     if response.status_code not in [200, 302, 301]:
         raise NotOkay(response)
     bgwork.perform()
     return response
Exemple #2
0
def _post_request(worker, request, environ={}):
    from canvas import bgwork, util
    from sentry.client.models import client

    try:
        bgwork.perform()
    except Exception, e:
        util.logger.exception('post_request error in bgwork.perform:' + e.message)
        client.create_from_exception()
def _post_request(worker, request, environ={}):
    from canvas import bgwork, util
    from raven.contrib.django.raven_compat.models import client

    try:
        bgwork.perform()
    except Exception, e:
        util.logger.exception('post_request error in bgwork.perform:' + e.message)
        client.captureException()
Exemple #4
0
def _post_request(worker, request, environ={}):
    from canvas import bgwork, util
    from raven.contrib.django.raven_compat.models import client

    try:
        bgwork.perform()
    except Exception, e:
        util.logger.exception('post_request error in bgwork.perform:' +
                              e.message)
        client.captureException()
Exemple #5
0
    def assertViewCount(self, request, response, count):
        now_dt = datetime.datetime.fromtimestamp(Services.time.time())

        bgwork.clear()
        RequestSetupMiddleware().process_request(request)
        RequestSetupMiddleware().process_response(request, response)
        
        view_previous = Metrics.view.daily_count(now_dt)
        bgwork.perform()
        view_current = Metrics.view.daily_count(now_dt)

        self.assertEqual(view_current - view_previous, count)
Exemple #6
0
    def test_deferred_method_not_called_on_failure(self):
        dwm = DeferredWorkMiddleware()
        request = HttpRequest()
        cb = CB()

        dwm.process_request(request)
        request.on_success.defer(cb)
        dwm.process_response(request, HttpResponse(status=500))

        bgwork.perform()

        self.assertEqual(cb.called, 0)
 def _http_verb(
     cls, verb, path, client=None, data=None, user=None, password=None, https=False, user_agent=None, **kwargs
 ):
     data = data or {}
     client = client or cls.get_client(user=user, password=password)
     if user_agent is not None:
         kwargs["HTTP_USER_AGENT"] = user_agent
     kwargs["HTTP_X_FORWARDED_PROTO"] = "https" if https else "http"  # Simulates ELB
     response = getattr(client, verb.lower())(path, data=data, **kwargs)
     if response.status_code not in [200, 302, 301]:
         raise NotOkay(response)
     bgwork.perform()
     return response
 def signup(self, username=None, extra_info=None, email=None, **kwargs):
     if not username:
         username = "******" % Autoincr.get()
     if email is None:
         email = generate_email(username)
     data = {"username": username, "password": "******", "email": email}
     data.update(kwargs)
     if extra_info is not None:
         data["info"] = extra_info
     response = self.post("/signup", data, user=AnonymousUser(), https=True)
     bgwork.perform()
     self.assertEqual(
         response.status_code,
         302,
         "The signup POST didn't redirect, which probably means that "
         "there was an error inside get_signup_context.",
     )
     return User.objects.get(username=username)
Exemple #9
0
 def signup(self, username=None, extra_info=None, email=None, **kwargs):
     if not username:
         username = "******" % Autoincr.get()
     if email is None:
         email = generate_email(username)
     data = {
         'username': username,
         'password': '******',
         'email': email,
         'code': InviteCode.generate().code,
     }
     data.update(kwargs)
     if extra_info is not None:
         data['info'] = extra_info
     response = self.post('/signup', data, user=AnonymousUser(), https=True)
     bgwork.perform()
     self.assertEqual(response.status_code, 302, "The signup POST didn't redirect, which probably means that "
                                                 "there was an error inside get_signup_context.")
     return User.objects.get(username=username)
 def tearDown(self):
     self.before_tearDown()
     bgwork.perform()
     self.restore_facebook()
Exemple #11
0
 def tearDown(self):
     self.before_tearDown()
     bgwork.perform()
     self.restore_facebook()