def test_extend_factory_overwrite_property(self):
        Factory.define(Tomato, color="green")
        Factory.extend(Tomato) ("red",
                                color="red")

        t = Factory(Tomato, "red")
        assert_true("red", t.color)
    def test_extend_factory_add_property(self):
        Factory.define(Tomato, color="green")
        Factory.extend(Tomato) ("with more power",
                                power="high")

        pure_tomato = Factory(Tomato)
        rich_tomato = Factory(Tomato, "with more power")

        assert_equals("high", rich_tomato.power)
    def test_extend_factory_with_differing_associations(self):
        Factory.define(Tomato, color=None)
        Factory.define(Vine, tomatoes=Factory.many(
            Factory.association(Tomato),
            Factory.association(Tomato)
        ))

        Factory.extend(Vine) (
            "with special tomatoes",
            tomatoes=Factory.many(
                Factory.association(Tomato, color="red"),
                Factory.association(Tomato, color="green")
            )
        )

        pure_vine = Factory(Vine)
        rich_vine = Factory(Vine, "with special tomatoes")

        assert_equals("green", rich_vine.tomatoes[1].color)
        assert_equals(None, pure_vine.tomatoes[1].color)
 def test_extend_nonexistent_factory(self):
     Factory.extend(Tomato) ("without first writing the base factory",
                             color="oops")