예제 #1
0
파일: formats.py 프로젝트: yiyibooks/pootle
def test_format_registry_extensions(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    filetype = registry.register("foo", "foo")

    # 2 filetypes can have the same extension
    filetype2 = registry.register("special_foo", "foo")
    assert str(filetype.extension) == "foo"
    assert str(filetype2.extension) == "foo"
    _test_formats(registry, ["foo", "special_foo"])
예제 #2
0
파일: formats.py 프로젝트: yiyibooks/pootle
def test_format_registry_instance(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    _test_formats(registry, [])
    filetype = registry.register("foo", "foo")
    assert isinstance(filetype, Format)
    assert filetype.name == "foo"
    assert filetype.title == "Foo"
    assert str(filetype.extension) == "foo"
    _test_formats(registry, ["foo"])
예제 #3
0
파일: formats.py 프로젝트: arky/pootle
def test_format_registry_instance(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    _test_formats(registry, [])
    filetype = registry.register("foo", "foo")
    assert isinstance(filetype, Format)
    assert filetype.name == "foo"
    assert filetype.title == "Foo"
    assert str(filetype.extension) == "foo"
    _test_formats(registry, ["foo"])
예제 #4
0
파일: formats.py 프로젝트: arky/pootle
def test_format_registry_extensions(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    filetype = registry.register("foo", "foo")

    # 2 filetypes can have the same extension
    filetype2 = registry.register("special_foo", "foo")
    assert str(filetype.extension) == "foo"
    assert str(filetype2.extension) == "foo"
    _test_formats(registry, ["foo", "special_foo"])
예제 #5
0
파일: formats.py 프로젝트: yiyibooks/pootle
def test_format_registry_template_extension(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    filetype = registry.register("foo", "foo", template_extension="bar")
    assert str(filetype.template_extension) == "bar"
    _test_formats(registry, ["foo"])

    # 2 filetypes can have the same template extensions
    filetype2 = registry.register("special_foo",
                                  "foo",
                                  template_extension="bar")
    assert str(filetype.template_extension) == "bar"
    assert str(filetype2.template_extension) == "bar"
    _test_formats(registry, ["foo", "special_foo"])
예제 #6
0
파일: formats.py 프로젝트: arky/pootle
def test_format_registry_template_extension(no_formats):
    """Tests the creation of a file extension
    """
    registry = FormatRegistry()
    filetype = registry.register(
        "foo", "foo", template_extension="bar")
    assert str(filetype.template_extension) == "bar"
    _test_formats(registry, ["foo"])

    # 2 filetypes can have the same template extensions
    filetype2 = registry.register(
        "special_foo", "foo", template_extension="bar")
    assert str(filetype.template_extension) == "bar"
    assert str(filetype2.template_extension) == "bar"
    _test_formats(registry, ["foo", "special_foo"])
예제 #7
0
파일: formats.py 프로젝트: arky/pootle
def test_format_registry_reregister(no_formats):
    """Tests the creation of a file extension
    """

    registry = FormatRegistry()
    filetype = registry.register("foo", "foo")

    # you can re-register the same format
    new_filetype = registry.register("foo", "foo")
    assert new_filetype == filetype
    _test_formats(registry, ["foo"])

    # but if you change anything it will be updated
    new_filetype = registry.register("foo", "foo", title="Bar")
    assert new_filetype == filetype
    assert new_filetype.title == "Bar"
    _test_formats(registry, ["foo"])

    new_filetype = registry.register("foo", "bar")
    assert new_filetype == filetype
    assert new_filetype.title == "Bar"
    assert str(new_filetype.extension) == "bar"
    _test_formats(registry, ["foo"])
예제 #8
0
파일: formats.py 프로젝트: yiyibooks/pootle
def test_format_registry_reregister(no_formats):
    """Tests the creation of a file extension
    """

    registry = FormatRegistry()
    filetype = registry.register("foo", "foo")

    # you can re-register the same format
    new_filetype = registry.register("foo", "foo")
    assert new_filetype == filetype
    _test_formats(registry, ["foo"])

    # but if you change anything it will be updated
    new_filetype = registry.register("foo", "foo", title="Bar")
    assert new_filetype == filetype
    assert new_filetype.title == "Bar"
    _test_formats(registry, ["foo"])

    new_filetype = registry.register("foo", "bar")
    assert new_filetype == filetype
    assert new_filetype.title == "Bar"
    assert str(new_filetype.extension) == "bar"
    _test_formats(registry, ["foo"])