def test_attribute_callback(self, basic_factory): """ Tests that the ``callback`` method will properly return the correct values. """ assoc = association(basic_factory, "ref") assert "YES" == assoc.callback(lambda x: "YES").resolve("attributes")
def test_shortcut_method(self, basic_factory): """ Tests that the shortcut method `association` works properly. """ assoc = association(basic_factory, "basic", attr="basic") assert isinstance(assoc, AssociationField) assert True == assoc.resolve("attributes")
def test_attribute_subfield(self, basic_factory): """ Tests that using the ``attribute`` method will properly use the parent schema to read the attributes. """ assoc = association(basic_factory, "ref") expected = assoc.resolve("attributes")["ref"] assert expected is assoc.attribute("ref").resolve("attributes")
def test_attribute_callback_read_attribute(self, basic_factory): """ Tests that the ``callback`` method can properly read the attributes using the dictionary syntax. """ def callback(assoc): return assoc["basic"] assoc = association(basic_factory, "basic") assert True == assoc.callback(callback).resolve("attributes")