Beispiel #1
0
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"])
Beispiel #2
0
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"])
Beispiel #3
0
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"])
Beispiel #4
0
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"])
Beispiel #5
0
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"])
Beispiel #6
0
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"])
Beispiel #7
0
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"])
Beispiel #8
0
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"])