def test_reciprocating_reciprocated(self):
     """ You can't reciprocate an already reciprocated property"""
     create_type(s, "Master", "master", domain_id)
     create_type(s, "Servant", "servant", domain_id)
     
     create_property(s, "Servants", "servants", domain_id + "/master", domain_id + "/servant", unique=False)
     reciprocate_property(s, "Masters", "masters", domain_id + "/master/servants", unique=False)
     
     self.assertRaises(MetawebError, lambda: reciprocate_property(s, "Buddies", "buddies", domain_id + "/master/servants", unique=False))
    def test_recreate_contractbridge_base(self):
        
        base = domain_id
        
        create_type(s, "Bridge Player", "bridge_player", base, tip="A bridge player", included=["/people/person", "/common/topic"])
        create_type(s, "Bridge Tournament", "bridge_tournament", base, tip="A bridge tournament", included=["/event/event", "/common/topic"])
        create_type(s, "Bridge Tournament Standings", "bridge_tournament_standings", base, cvt=True, tip="Bridge Tournamen Results")

        player = base + "/bridge_player"
        tourney = base + "/bridge_tournament"
        standing = base + "/bridge_tournament_standings"

        # tournament standings
        # ideas: create a cvt could be a function, disambig always True, same schema, iono, whatever
        create_property(s, "Year", "year", standing, "/type/datetime", True, disambig=True, tip="Year")
        create_property(s, "First Place", "first_place", standing, player, False, disambig=True)
        create_property(s, "Second Place", "second_place", standing, player, False, disambig=True)
        create_property(s, "Tournament", "tournament", standing, tourney, True, disambig=True)


        # tournament
        reciprocate_property(s, "Standing", "standing", standing + "/tournament", False, disambig=True)
        create_property(s, "Location", "location", tourney, "/location/citytown", False, disambig=True)

        # bridge player
        # standings must be reverses!
        reciprocate_property(s, "First Place Finish", "first_place_finish", standing + "/first_place", False, False)
        reciprocate_property(s, "Second Place Finish", "second_place_finish", standing + "/second_place", False, False)

        #delegator property test
        delegate_property(s, "/people/person/date_of_birth", player, "Date of Birth", "db")
    def test_reciprocating_reciprocated(self):
        """ You can't reciprocate an already reciprocated property"""
        create_type(s, "Master", "master", domain_id)
        create_type(s, "Servant", "servant", domain_id)

        create_property(s,
                        "Servants",
                        "servants",
                        domain_id + "/master",
                        domain_id + "/servant",
                        unique=False)
        reciprocate_property(s,
                             "Masters",
                             "masters",
                             domain_id + "/master/servants",
                             unique=False)

        self.assertRaises(
            MetawebError,
            lambda: reciprocate_property(s,
                                         "Buddies",
                                         "buddies",
                                         domain_id + "/master/servants",
                                         unique=False))
    def test_recreate_contractbridge_base(self):

        base = domain_id

        create_type(s,
                    "Bridge Player",
                    "bridge_player",
                    base,
                    tip="A bridge player",
                    included=["/people/person", "/common/topic"])
        create_type(s,
                    "Bridge Tournament",
                    "bridge_tournament",
                    base,
                    tip="A bridge tournament",
                    included=["/event/event", "/common/topic"])
        create_type(s,
                    "Bridge Tournament Standings",
                    "bridge_tournament_standings",
                    base,
                    cvt=True,
                    tip="Bridge Tournamen Results")

        player = base + "/bridge_player"
        tourney = base + "/bridge_tournament"
        standing = base + "/bridge_tournament_standings"

        # tournament standings
        # ideas: create a cvt could be a function, disambig always True, same schema, iono, whatever
        create_property(s,
                        "Year",
                        "year",
                        standing,
                        "/type/datetime",
                        True,
                        disambig=True,
                        tip="Year")
        create_property(s,
                        "First Place",
                        "first_place",
                        standing,
                        player,
                        False,
                        disambig=True)
        create_property(s,
                        "Second Place",
                        "second_place",
                        standing,
                        player,
                        False,
                        disambig=True)
        create_property(s,
                        "Tournament",
                        "tournament",
                        standing,
                        tourney,
                        True,
                        disambig=True)

        # tournament
        reciprocate_property(s,
                             "Standing",
                             "standing",
                             standing + "/tournament",
                             False,
                             disambig=True)
        create_property(s,
                        "Location",
                        "location",
                        tourney,
                        "/location/citytown",
                        False,
                        disambig=True)

        # bridge player
        # standings must be reverses!
        reciprocate_property(s, "First Place Finish", "first_place_finish",
                             standing + "/first_place", False, False)
        reciprocate_property(s, "Second Place Finish", "second_place_finish",
                             standing + "/second_place", False, False)

        #delegator property test
        delegate_property(s, "/people/person/date_of_birth", player,
                          "Date of Birth", "db")