Exemplo n.º 1
0
    def test_html_description_method(self, mocker):

        with mocker.patch("ddionrails.mixins.render_markdown"):
            mixin = ModelMixin()
            mixin.description = "some-description"
            mixin.html_description()
            ddionrails.mixins.render_markdown.assert_called_once()
Exemplo n.º 2
0
 def test_to_dict_method(self):
     mixin = ModelMixin()
     mixin.name = "some-name"
     mixin.label = "some-label"
     mixin.description = "some-description"
     dictionary = mixin.to_dict()
     expected = dict(
         name="some-name", label="some-label", description="some-description"
     )
     assert dictionary == expected
Exemplo n.º 3
0
 def test_get_attribute_method(self):
     mixin = ModelMixin()
     mixin.name = "some-name"
     result = mixin.get_attribute("self.name")
     assert result == mixin.name
Exemplo n.º 4
0
 def test_html_description_method_without_description(self, mocker):
     mixin = ModelMixin()
     result = mixin.html_description()
     assert result == ""
Exemplo n.º 5
0
 def test_title_method_with_label(self):
     mixin = ModelMixin()
     mixin.label = "some-label"
     assert mixin.title() is mixin.label
Exemplo n.º 6
0
 def test_title_method_with_name(self):
     mixin = ModelMixin()
     mixin.name = "some-name"
     assert mixin.title() is mixin.name
Exemplo n.º 7
0
 def test_title_method(self):
     mixin = ModelMixin()
     result = mixin.title()
     assert result is ""
Exemplo n.º 8
0
 def test_string_method(self, mocker):
     mixin = ModelMixin()
     with mocker.patch("ddionrails.mixins.ModelMixin.string_id", return_value=""):
         assert str(mixin) == ""
         mixin.string_id.assert_called_once()
Exemplo n.º 9
0
 def test_string_id_method_multiple_id_field(self):
     mixin = ModelMixin()
     mixin.DOR.id_fields = ["id1", "id2"]
     mixin.id1 = "name-1"
     mixin.id2 = "name-2"
     assert mixin.string_id() == mixin.id1 + "/" + mixin.id2
Exemplo n.º 10
0
 def test_string_id_method_single_id_field(self):
     mixin = ModelMixin()
     mixin.name = "some-name"
     assert mixin.string_id() == mixin.name
Exemplo n.º 11
0
 def test_get_attribute_method_default(self):
     mixin = ModelMixin()
     result = mixin.get_attribute("self.name")
     assert result is None