Example #1
0
    def test_content_metadata_list_field_does_not_render_template_fields(self):
        metadata = ContentMetadata(
            {'nested': [TemplateField('Name'),
                        TemplateField('{{ name }}')]})

        assert metadata.nested == [
            TemplateField('Name'),
            TemplateField('{{ name }}')
        ]
    def test_metadata_repr(self):
        metadata = ContentMetadata({"name": "value"})

        assert metadata.__repr__() == "<ContentMetadata: data={'name': 'value'}>"
    def test_get_missing_field(self):
        metadata = ContentMetadata({})

        assert metadata.get('key', 'default') == 'default'
Example #4
0
    def test_content_metadata_getattr(self):
        metadata = ContentMetadata({'name': "Name"})

        assert metadata.name == 'Name'
Example #5
0
    def test_content_metadata_does_not_render_template_fields(self):
        metadata = ContentMetadata({'name': TemplateField("Field {{ name }}")})

        assert metadata.name == TemplateField('Field {{ name }}')
Example #6
0
    def test_content_metadata_dict_field_returns_content_metadata(self):
        metadata = ContentMetadata({'nested': {'name': 'Name'}})

        assert isinstance(metadata.nested, ContentMetadata)
        assert metadata.nested.name == 'Name'
Example #7
0
    def test_metadata_repr(self):
        metadata = ContentMetadata({"name": "value"})

        assert metadata.__repr__(
        ) == "<ContentMetadata: data={'name': 'value'}>"
Example #8
0
    def test_metadata_get_item(self):
        metadata = ContentMetadata({"name": "value"})

        assert metadata['name'] == 'value'
Example #9
0
    def test_metadata_eq(self):
        metadata = ContentMetadata({"name": "value"})

        assert metadata == ContentMetadata({"name": "value"})
        assert metadata != {"name": "value"}
Example #10
0
    def test_get_missing_field(self):
        metadata = ContentMetadata({})

        assert metadata.get('key', 'default') == 'default'
Example #11
0
    def test_content_metadata_getattr_raises_attribute_error_if_missing(self):
        metadata = ContentMetadata({'name': "Name"})

        with pytest.raises(AttributeError):
            assert metadata.foo == 'missing'