Example #1
0
def test_view_tp_export_garbage(client, tp0, language1, request_users):
    url = ("%s?path=/%s/%s/" %
           (reverse('pootle-export'), tp0.language.code, tp0.project.code))
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    client.get(url)
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
    url = ("%s?path=/%s/%s/" %
           (reverse('pootle-export'), language1.code, tp0.project.code))
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #2
0
def test_submit_unit_memusage(client, store0, admin, settings, system):
    settings.POOTLE_CAPTCHA_ENABLED = False
    user = admin
    unit = store0.units.filter(state=UNTRANSLATED).first()
    if user.username != "nobody":
        client.login(
            username=user.username,
            password="******")
    url = '/xhr/units/%d/' % unit.id
    response = client.post(
        url,
        dict(target_f_0=("%s changed" % unit.target),
             is_fuzzy="0",
             sfn="PTL.editor.processSubmission"),
        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.post(
                url,
                dict(target_f_0=("%s changed" % unit.target),
                     is_fuzzy="0",
                     sfn="PTL.editor.processSubmission"),
                HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]
Example #3
0
def test_view_welcome_garbage(client):
    url = reverse("pootle-home")
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #4
0
def test_view_welcome_garbage(client):
    url = reverse("pootle-home")
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #5
0
def test_get_units_memusage(client, tp0, request_users, settings, system):
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    url = ('/xhr/units/?path=/%s/%s/' % (tp0.language.code, tp0.project.code))
    response = client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]
Example #6
0
def test_view_language_garbage(language0, store0, client, request_users):
    url = reverse("pootle-language-browse",
                  kwargs=dict(language_code=language0.code))
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #7
0
def test_view_user_detail_garbage(member, client, request_users):
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    response = client.get(
        reverse('pootle-user-profile', kwargs=dict(username=member.username)))
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(
                reverse('pootle-user-profile',
                        kwargs=dict(username=member.username)))
        assert usage["used"] == 0
Example #8
0
def test_get_edit_unit_memusage(client, store0, request_users, settings,
                                system):
    user = request_users["user"]
    unit = store0.units.filter(state=UNTRANSLATED).first()
    client.login(username=user.username, password=request_users["password"])
    url = ('/xhr/units/%s/edit' % unit.id)
    response = client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]
Example #9
0
def test_debug_memusage():
    """Site wide update_stores"""
    gc.collect()

    initial = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

    with memusage() as usage:
        foo = "BAR"

    assert foo
    assert usage["initial"] >= initial
    assert usage["after"] >= initial
    assert "used" in usage
Example #10
0
def test_debug_memusage():
    """Site wide update_stores"""
    gc.collect()

    initial = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

    with memusage() as usage:
        foo = "BAR"

    assert foo
    assert usage["initial"] >= initial
    assert usage["after"] >= initial
    assert "used" in usage
Example #11
0
def test_view_tp_store_garbage(store0, client, request_users):
    tp = store0.translation_project
    args = [tp.language.code, tp.project.code, store0.name]
    url = reverse("pootle-tp-store-browse", args=args)
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #12
0
def test_view_tp_store_garbage(store0, client, request_users):
    tp = store0.translation_project
    args = [tp.language.code, tp.project.code, store0.name]
    url = reverse("pootle-tp-store-browse", args=args)
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #13
0
def test_view_language_garbage(language0, store0, client, request_users):
    url = reverse(
        "pootle-language-browse",
        kwargs=dict(
            language_code=language0.code))
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #14
0
def test_view_tp_garbage(tp0, store0, client, request_users):
    args = [tp0.language.code, tp0.project.code]
    url = reverse("pootle-tp-browse", args=args)
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    failed = []
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        try:
            assert usage["used"] == 0
        except:
            failed.append((i, usage["used"]))
    assert not failed
Example #15
0
def test_view_user_detail_garbage(member, client, request_users):
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(
        reverse(
            'pootle-user-profile',
            kwargs=dict(username=member.username)))
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(
                reverse(
                    'pootle-user-profile',
                    kwargs=dict(username=member.username)))
        assert usage["used"] == 0
Example #16
0
def test_get_units_memusage(client, tp0, request_users, settings, system):
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    url = (
        '/xhr/units/?path=/%s/%s/'
        % (tp0.language.code, tp0.project.code))
    response = client.get(
        url,
        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(
                url,
                HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]
Example #17
0
def test_get_edit_unit_memusage(client, store0, request_users, settings, system):
    user = request_users["user"]
    unit = store0.units.filter(state=UNTRANSLATED).first()
    client.login(
        username=user.username,
        password=request_users["password"])
    url = (
        '/xhr/units/%s/edit' % unit.id)
    response = client.get(
        url,
        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(
                url,
                HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]
Example #18
0
def test_view_project_store_garbage(store0, client, request_users):
    url = reverse(
        "pootle-project-browse",
        kwargs=dict(
            project_code=store0.translation_project.project.code,
            dir_path="",
            filename=store0.name))
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        assert not usage["used"]
Example #19
0
def test_view_tp_garbage(tp0, store0, client, request_users):
    args = [tp0.language.code, tp0.project.code]
    url = reverse("pootle-tp-browse", args=args)
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(url)
    response = client.get(url)
    assert response.status_code == 200
    failed = []
    for i in xrange(0, 2):
        with memusage() as usage:
            client.get(url)
        try:
            assert usage["used"] == 0
        except:
            failed.append((i, usage["used"]))
    assert not failed
Example #20
0
def test_submit_unit_memusage(client, store0, admin, settings, system):
    settings.POOTLE_CAPTCHA_ENABLED = False
    user = admin
    unit = store0.units.filter(state=UNTRANSLATED).first()
    if user.username != "nobody":
        client.login(username=user.username, password="******")
    url = '/xhr/units/%d/' % unit.id
    response = client.post(url,
                           dict(target_f_0=("%s changed" % unit.target),
                                is_fuzzy="0",
                                sfn="PTL.editor.processSubmission"),
                           HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    assert response.status_code == 200
    for i in xrange(0, 2):
        with memusage() as usage:
            client.post(url,
                        dict(target_f_0=("%s changed" % unit.target),
                             is_fuzzy="0",
                             sfn="PTL.editor.processSubmission"),
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        assert not usage["used"]