Example #1
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)
Example #2
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"
Example #3
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"
Example #4
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)
Example #5
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)
Example #6
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)