示例#1
0
def test_form_project_template_name(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1
    }
    form = ProjectForm(form_data)
    assert form.is_valid()
    assert form.cleaned_data["template_name"] == ""
    project = form.save()
    assert project.lang_mapper.get_upstream_code("templates") == "templates"
    form_data["template_name"] = "foo"
    form = ProjectForm(instance=project, data=form_data)
    assert form.is_valid()
    form.save()
    del project.__dict__["lang_mapper"]
    assert project.lang_mapper.get_upstream_code("templates") == "foo"
    form_data["template_name"] = ""
    form = ProjectForm(instance=project, data=form_data)
    assert form.is_valid()
    form.save()
    del project.__dict__["lang_mapper"]
    assert project.lang_mapper.get_upstream_code("templates") == "templates"
示例#2
0
def test_form_project_fs_mapping(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1
    }
    form = ProjectForm(form_data)
    assert form.is_valid()
    form_data["fs_mapping"] = "<language_code>.<ext>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'fs_mapping' in form.errors
    form_data["fs_mapping"] = "/<language_code>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'fs_mapping' in form.errors
    form_data["fs_mapping"] = "/<foo_code>.<ext>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'fs_mapping' in form.errors
示例#3
0
def test_form_project_fs_mapping(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert form.is_valid()
    mapping_errors = {
        'fs_mapping': [
            'Filesystem mapping should start with "/", '
            'end with ".<ext>", and contain "<language_code>"']}
    form_data["fs_mapping"] = "<language_code>.<ext>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert form.errors == mapping_errors
    form_data["fs_mapping"] = "/<language_code>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert form.errors == mapping_errors
    form_data["fs_mapping"] = "/<foo_code>.<ext>"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert form.errors == mapping_errors
示例#4
0
文件: projects.py 项目: phlax/pootle
    def get_context_data(self, **kwargs):
        languages = Language.objects.exclude(code="templates")
        language_choices = [(lang.id, unicode(lang)) for lang in languages]
        try:
            english = Language.objects.get(code="en")
            default_language = english.id
        except Language.DoesNotExist:
            default_language = languages[0].id

        filetypes = []
        for info in formats.get().values():
            filetypes.append([info["pk"], info["display_title"]])

        project_checker_choices = [(checker, checker) for checker in sorted(PROJECT_CHECKERS.keys())]

        return {
            "page": "admin-projects",
            "form_choices": {
                "checkstyle": project_checker_choices,
                "filetypes": filetypes,
                "source_language": language_choices,
                "treestyle": Project.treestyle_choices,
                "defaults": {"source_language": default_language},
            },
        }
示例#5
0
def test_admin_view_projects(client, request_users, english):
    user = request_users["user"]

    client.login(
        username=user.username,
        password=request_users["password"])

    response = client.get(
        reverse(
            "pootle-admin-projects"))

    if not user.is_superuser:
        assert response.status_code == 403
        return
    languages = Language.objects.exclude(code='templates')
    language_choices = [(lang.id, unicode(lang)) for lang in languages]
    filetypes = []
    for info in formats.get().values():
        filetypes.append(
            [info["pk"], info["display_title"]])
    project_checker_choices = [
        (checker, checker)
        for checker
        in sorted(PROJECT_CHECKERS.keys())]
    expected = {
        'page': 'admin-projects',
        'form_choices': {
            'checkstyle': project_checker_choices,
            'filetypes': filetypes,
            'source_language': language_choices,
            'treestyle': Project.treestyle_choices,
            'defaults': {
                'source_language': english.id}}}
    for k, v in expected.items():
        assert response.context_data[k] == v
示例#6
0
文件: project.py 项目: arky/pootle
def test_project_form_change_filetypes(format_registry):
    filetype_names = ["xliff", "po", "ts"]
    filetypes = []
    for filetype in filetype_names:
        filetypes.append(Format.objects.get(name=filetype).pk)
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': filetypes,
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}project0",
        'fs_mapping': "/<language_code>.<ext>",
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': ""}
    project0 = Project.objects.get(code="project0")
    form = ProjectForm(form_data, instance=project0)
    assert form.is_valid()
    form.save()
    assert (
        list(project0.filetypes.values_list("pk", flat=True))
        == filetypes)
示例#7
0
    def get_context_data(self, **kwargs):
        languages = Language.objects.exclude(code='templates')
        language_choices = [(lang.id, unicode(lang)) for lang in languages]
        try:
            english = Language.objects.get(code='en')
            default_language = english.id
        except Language.DoesNotExist:
            default_language = languages[0].id

        filetypes = []
        for info in formats.get().values():
            filetypes.append([info["pk"], info["display_title"]])

        project_checker_choices = [
            (checker, checker) for checker in sorted(PROJECT_CHECKERS.keys())
        ]
        plugin_choices = sorted([(x, x) for x in fs_plugins.gather()])
        fs_presets = FS_PRESETS.values()
        return {
            'page': 'admin-projects',
            'form_choices': {
                'checkstyle': project_checker_choices,
                'filetypes': filetypes,
                'fs_plugin': plugin_choices,
                'fs_preset': fs_presets,
                'source_language': language_choices,
                'defaults': {
                    'source_language': default_language,
                },
            },
        }
示例#8
0
文件: project.py 项目: arky/pootle
def test_form_project_template_name(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert form.is_valid()
    assert form.cleaned_data["template_name"] == ""
    project = form.save()
    assert project.lang_mapper.get_upstream_code("templates") == "templates"
    form_data["template_name"] = "foo"
    form = ProjectForm(instance=project, data=form_data)
    assert form.is_valid()
    form.save()
    del project.__dict__["lang_mapper"]
    assert project.lang_mapper.get_upstream_code("templates") == "foo"
    form_data["template_name"] = ""
    form = ProjectForm(instance=project, data=form_data)
    assert form.is_valid()
    form.save()
    del project.__dict__["lang_mapper"]
    assert project.lang_mapper.get_upstream_code("templates") == "templates"
示例#9
0
文件: projects.py 项目: arky/pootle
    def get_context_data(self, **kwargs):
        languages = Language.objects.exclude(code='templates')
        language_choices = [(lang.id, unicode(lang)) for lang in languages]
        try:
            english = Language.objects.get(code='en')
            default_language = english.id
        except Language.DoesNotExist:
            default_language = languages[0].id

        filetypes = []
        for info in formats.get().values():
            filetypes.append(
                [info["pk"], info["display_title"]])

        project_checker_choices = [
            (checker, checker)
            for checker
            in sorted(PROJECT_CHECKERS.keys())]
        plugin_choices = sorted([(x, x) for x in fs_plugins.gather()])
        fs_presets = FS_PRESETS.values()
        return {
            'page': 'admin-projects',
            'form_choices': {
                'checkstyle': project_checker_choices,
                'filetypes': filetypes,
                'fs_plugin': plugin_choices,
                'fs_preset': fs_presets,
                'source_language': language_choices,
                'defaults': {
                    'source_language': default_language,
                },
            },
        }
示例#10
0
def test_admin_view_projects(client, request_users, english):
    user = request_users["user"]

    client.login(username=user.username, password=request_users["password"])

    response = client.get(reverse("pootle-admin-projects"))

    if not user.is_superuser:
        assert response.status_code == 403
        return
    languages = Language.objects.exclude(code='templates')
    language_choices = [(lang.id, unicode(lang)) for lang in languages]
    filetypes = []
    for info in formats.get().values():
        filetypes.append([info["pk"], info["display_title"]])
    project_checker_choices = [(checker, checker)
                               for checker in sorted(PROJECT_CHECKERS.keys())]
    expected = {
        'page': 'admin-projects',
        'form_choices': {
            'checkstyle': project_checker_choices,
            'filetypes': filetypes,
            'source_language': language_choices,
            'treestyle': Project.treestyle_choices,
            'defaults': {
                'source_language': english.id
            }
        }
    }
    for k, v in expected.items():
        assert response.context_data[k] == v
示例#11
0
def test_clean_code_blank_invalid():
    form_data = {
        'code': '  ',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'source_language': 1,
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'code' in form.errors
    assert len(form.errors.keys()) == 1
示例#12
0
文件: project.py 项目: sshyran/zing
def test_clean_code_blank_invalid():
    form_data = {
        "code": "  ",
        "checkstyle": list(PROJECT_CHECKERS.keys())[0],
        "fullname": "Foo",
        "source_language": 1,
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert "code" in form.errors
    assert len(list(form.errors.keys())) == 1
示例#13
0
def test_clean_code_invalid(reserved_code, format_registry):
    form_data = {
        'code': reserved_code,
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1,
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'code' in form.errors
    assert len(form.errors.keys()) == 1
示例#14
0
def test_clean_localfiletype_invalid(format_registry):
    form_data = {
        'code': 'foo',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'filetypes': ["NO_SUCH_FORMAT"],
        'source_language': 1,
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#15
0
def test_clean_localfiletype_invalid(format_registry):
    form_data = {
        'code': 'foo',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'filetypes': ["NO_SUCH_FORMAT"],
        'source_language': 1,
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#16
0
def test_clean_code_invalid(reserved_code, format_registry):
    form_data = {
        'code': reserved_code,
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1,
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'code' in form.errors
    assert len(form.errors.keys()) == 1
示例#17
0
文件: project.py 项目: arky/pootle
def test_form_project_plugin_missing(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'fs_plugin' in form.errors
    assert len(form.errors.keys()) == 1
示例#18
0
文件: project.py 项目: arky/pootle
def test_clean_localfiletype_invalid(format_registry):
    form_data = {
        'code': 'foo',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': ["NO_SUCH_FORMAT"],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#19
0
文件: project.py 项目: arky/pootle
def test_clean_code_invalid(reserved_code, format_registry):
    form_data = {
        'code': reserved_code,
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_mapping': "/<language_code>.<ext>",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}%s" % reserved_code,
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'code' in form.errors
    assert len(form.errors.keys()) == 1
示例#20
0
def test_clean_localfiletype_invalid(format_registry):
    form_data = {
        'code': 'foo',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': ["NO_SUCH_FORMAT"],
        'source_language': 1
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#21
0
def test_clean_code_invalid(reserved_code, format_registry):
    form_data = {
        'code': reserved_code,
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_mapping': "/<language_code>.<ext>",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}%s" % reserved_code,
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'code' in form.errors
    assert len(form.errors.keys()) == 1
示例#22
0
def test_form_project_plugin_invalid(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "DOES NOT EXIST",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1
    }
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert 'fs_plugin' in form.errors
    assert len(form.errors.keys()) == 1
示例#23
0
def test_project_form_bad_filetype_removal(format_registry):
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': [Format.objects.get(name="xliff").pk],
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': "",
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data, instance=Project.objects.get(code="project0"))
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#24
0
def test_project_form_bad_filetype_removal(format_registry):
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': [Format.objects.get(name="xliff").pk],
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': "",
        'treestyle': Project.treestyle_choices[0][0],
    }
    form = ProjectForm(form_data, instance=Project.objects.get(code="project0"))
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#25
0
文件: project.py 项目: arky/pootle
def test_project_form_bad_filetype_removal(format_registry):
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}project0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [Format.objects.get(name="xliff").pk],
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': ""}
    form = ProjectForm(form_data, instance=Project.objects.get(code="project0"))
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#26
0
def test_project_form_bad_filetype_removal(format_registry):
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}project0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [Format.objects.get(name="xliff").pk],
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': ""
    }
    form = ProjectForm(form_data,
                       instance=Project.objects.get(code="project0"))
    assert not form.is_valid()
    assert 'filetypes' in form.errors
    assert len(form.errors.keys()) == 1
示例#27
0
def test_project_form_change_filetypes(format_registry):
    filetype_names = ["xliff", "po", "ts"]
    filetypes = []
    for filetype in filetype_names:
        filetypes.append(Format.objects.get(name=filetype).pk)
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': filetypes,
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': "",
        'treestyle': Project.treestyle_choices[0][0],
    }
    project0 = Project.objects.get(code="project0")
    form = ProjectForm(form_data, instance=project0)
    assert form.is_valid()
    form.save()
    assert (list(project0.filetypes.values_list("pk", flat=True)) == filetypes)
示例#28
0
文件: project.py 项目: arky/pootle
def test_form_project_fs_url(format_registry):
    form_data = {
        'code': 'foo0',
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'fullname': 'Foo',
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}foo0",
        'fs_mapping': "/<language_code>.<ext>",
        'filetypes': [format_registry["po"]["pk"]],
        'source_language': 1}
    form = ProjectForm(form_data)
    assert form.is_valid()
    form_data["fs_url"] = "/foo/bar/baz"
    form = ProjectForm(form_data)
    assert form.is_valid()
    form_data["fs_url"] = "foo/bar/baz"
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert form.errors.keys() == ["fs_url"]
    form_data["fs_url"] = ""
    form = ProjectForm(form_data)
    assert not form.is_valid()
    assert form.errors.keys() == ["fs_url"]
示例#29
0
def test_project_form_change_filetypes(format_registry):
    filetype_names = ["xliff", "po", "ts"]
    filetypes = []
    for filetype in filetype_names:
        filetypes.append(Format.objects.get(name=filetype).pk)
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': filetypes,
        'fs_plugin': "localfs",
        'fs_url': "{POOTLE_TRANSLATION_DIRECTORY}project0",
        'fs_mapping': "/<language_code>.<ext>",
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': ""
    }
    project0 = Project.objects.get(code="project0")
    form = ProjectForm(form_data, instance=project0)
    assert form.is_valid()
    form.save()
    assert (list(project0.filetypes.values_list("pk", flat=True)) == filetypes)
示例#30
0
def test_project_form_change_filetypes(format_registry):
    filetype_names = ["xliff", "po", "ts"]
    filetypes = []
    for filetype in filetype_names:
        filetypes.append(Format.objects.get(name=filetype).pk)
    form_data = {
        'fullname': "Project 0",
        'code': "project0",
        'checkstyle': PROJECT_CHECKERS.keys()[0],
        'disabled': False,
        'filetypes': filetypes,
        'source_language': 1,
        'screenshot_search_prefix': "",
        'ignoredfiles': "",
        'report_email': "",
        'treestyle': Project.treestyle_choices[0][0],
    }
    project0 = Project.objects.get(code="project0")
    form = ProjectForm(form_data, instance=project0)
    assert form.is_valid()
    form.save()
    assert (
        list(project0.filetypes.values_list("pk", flat=True))
        == filetypes)
示例#31
0
    def add_arguments(self, parser):
        format_names = formats.get().keys()
        fs_plugins_names = fs_plugins.gather().keys()

        parser.add_argument(
            'code',
            action='store',
            help='Project code',
        )
        parser.add_argument(
            "--name",
            action="store",
            dest="name",
            help="Project name",
        )
        parser.add_argument(
            "--filetype",
            action="append",
            dest="filetypes",
            choices=format_names,
            default=[],
            help="File types: {0}. Default: po".format(
                 " | ".join(format_names)),
        )
        mapping_group = parser.add_mutually_exclusive_group(required=True)
        mapping_group.add_argument(
            "--preset-mapping",
            action="store",
            dest="preset_mapping",
            choices=FS_PRESETS.keys(),
            help="Filesystem layout preset: {0}".format(
                 " | ".join(FS_PRESETS.keys())),
        )
        mapping_group.add_argument(
            "--mapping",
            action="store",
            dest="mapping",
            help="Custom filesystem layout",
        )
        parser.add_argument(
            "--fs-type",
            action="store",
            dest="fs_type",
            default="localfs",
            choices=fs_plugins_names,
            help="Filesystem type: {0}".format(" | ".join(fs_plugins_names)),
        )
        parser.add_argument(
            "--fs-url",
            action="store",
            dest="fs_url",
            default="",
            help="Filesystem path or URL.",
        )
        parser.add_argument(
            "--source-language",
            action="store",
            dest="sourcelang",
            default="en",
            help=("Source language. Examples: [en | es | fr | ...]."
                  "Default: %(default)s"),
        )
        parser.add_argument(
            "--report-email",
            action="store",
            default="",
            dest="contact",
            help="Contact email for reports. Example: [email protected].",
        )
        parser.add_argument(
            "--disabled",
            action="store_true",
            dest="disabled",
            help="Does the project start disabled?",
        )
        parser.add_argument(
            "--checkstyle",
            action="store",
            dest="checkstyle",
            choices=PROJECT_CHECKERS.keys(),
            default="standard",
            help="Quality check styles. Example: {0}. Default: %(default)s"
                 .format(" | ".join(PROJECT_CHECKERS.keys())),
        )
示例#32
0
def pytest_generate_tests(metafunc):
    from pootle_project.models import PROJECT_CHECKERS

    if 'checkers' in metafunc.funcargnames:
        metafunc.parametrize("checkers", PROJECT_CHECKERS.keys())
示例#33
0
def pytest_generate_tests(metafunc):
    from pootle_project.models import PROJECT_CHECKERS

    if 'checkers' in metafunc.funcargnames:
        metafunc.parametrize("checkers", PROJECT_CHECKERS.keys())
示例#34
0
    def add_arguments(self, parser):
        format_names = formats.get().keys()
        fs_plugins_names = fs_plugins.gather().keys()

        parser.add_argument(
            'code',
            action='store',
            help='Project code',
        )
        parser.add_argument(
            "--name",
            action="store",
            dest="name",
            help="Project name",
        )
        parser.add_argument(
            "--filetype",
            action="append",
            dest="filetypes",
            choices=format_names,
            default=[],
            help="File types: {0}. Default: po".format(
                " | ".join(format_names)),
        )
        mapping_group = parser.add_mutually_exclusive_group(required=True)
        mapping_group.add_argument(
            "--preset-mapping",
            action="store",
            dest="preset_mapping",
            choices=FS_PRESETS.keys(),
            help="Filesystem layout preset: {0}".format(" | ".join(
                FS_PRESETS.keys())),
        )
        mapping_group.add_argument(
            "--mapping",
            action="store",
            dest="mapping",
            help="Custom filesystem layout",
        )
        parser.add_argument(
            "--fs-type",
            action="store",
            dest="fs_type",
            default="localfs",
            choices=fs_plugins_names,
            help="Filesystem type: {0}".format(" | ".join(fs_plugins_names)),
        )
        parser.add_argument(
            "--fs-url",
            action="store",
            dest="fs_url",
            default="",
            help="Filesystem path or URL.",
        )
        parser.add_argument(
            "--source-language",
            action="store",
            dest="sourcelang",
            default="en",
            help=("Source language. Examples: [en | es | fr | ...]."
                  "Default: %(default)s"),
        )
        parser.add_argument(
            "--report-email",
            action="store",
            default="",
            dest="contact",
            help="Contact email for reports. Example: [email protected].",
        )
        parser.add_argument(
            "--disabled",
            action="store_true",
            dest="disabled",
            help="Does the project start disabled?",
        )
        parser.add_argument(
            "--checkstyle",
            action="store",
            dest="checkstyle",
            choices=PROJECT_CHECKERS.keys(),
            default="standard",
            help="Quality check styles. Example: {0}. Default: %(default)s".
            format(" | ".join(PROJECT_CHECKERS.keys())),
        )