Skip to content

Commit

Permalink
Add virtualfolder view tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phlax committed Sep 8, 2016
1 parent 4f15c28 commit f3e344f
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/views/vf.py
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

import pytest

from django.core.urlresolvers import reverse


@pytest.mark.django_db
def test_view_vf_tp_translate_reverse():
# tp translate views
tp_translate_view = reverse(
"vfolder-pootle-tp-translate",
kwargs=dict(
vfolder_name="VF_NAME",
language_code="LANG_CODE",
project_code="PROJ_CODE"))
assert (
tp_translate_view
== u'/++vfolder/VF_NAME/LANG_CODE/PROJ_CODE/translate/')
tp_translate_subdir_view = reverse(
"vfolder-pootle-tp-translate",
kwargs=dict(
vfolder_name="VF_NAME",
language_code="LANG_CODE",
project_code="PROJ_CODE",
dir_path="SOME/SUBDIR/"))
assert (
tp_translate_subdir_view
== u'/++vfolder/VF_NAME/LANG_CODE/PROJ_CODE/translate/SOME/SUBDIR/')


@pytest.mark.django_db
def test_view_vf_tp_translate_store_reverse():
tp_translate_store_view = reverse(
"vfolder-pootle-tp-store-translate",
kwargs=dict(
vfolder_name="VF_NAME",
language_code="LANG_CODE",
project_code="PROJ_CODE",
filename="FILE.EXT"))
assert (
tp_translate_store_view
== u'/++vfolder/VF_NAME/LANG_CODE/PROJ_CODE/translate/FILE.EXT')
tp_translate_subdir_store_view = reverse(
"vfolder-pootle-tp-store-translate",
kwargs=dict(
vfolder_name="VF_NAME",
language_code="LANG_CODE",
project_code="PROJ_CODE",
dir_path="SOME/SUBDIR/",
filename="FILE.EXT"))
assert (
tp_translate_subdir_store_view
== u'/++vfolder/VF_NAME/LANG_CODE/PROJ_CODE/translate/SOME/SUBDIR/FILE.EXT')


@pytest.mark.pootle_vfolders
@pytest.mark.django_db
def test_views_vf_translate(vfolder_views, settings):
from tp import _test_browse_view, _test_translate_view
test_type, tp, request, response, kwargs = vfolder_views
if test_type == "browse":
_test_browse_view(tp, request, response, kwargs)
elif test_type == "translate":
_test_translate_view(tp, request, response, kwargs, settings)

0 comments on commit f3e344f

Please sign in to comment.