def test_merge_merges_note_2(self):
        share1 = ShareFactory.create()
        share2 = ShareFactory.create(note="Note 2")

        merge(share1.id, share2.id)

        assert Share.query.one().note == "Note 2"
    def test_merge_other_way(self):
        share1 = ShareFactory.create()
        share2 = ShareFactory.create()

        MemberFactory.create(share=share1)
        MemberFactory.create(share=share2)
        MemberFactory.create(share=share2)

        BetFactory.create(share=share1)
        BetFactory.create(share=share1)
        BetFactory.create(share=share2)


        assert Share.query.count() == 2
        assert Bet.query.count() == 3

        merge(share2.id, share1.id)

        updated_share = Share.query.one()

        assert Share.query.count() == 1
        assert len(updated_share.members) == 3
        assert len(updated_share.bets) == 3
        assert Member.query.count() == 3
        assert Bet.query.count() == 3
示例#3
0
    def test_merge_merges_note_2(self):
        share1 = ShareFactory.create()
        share2 = ShareFactory.create(note="Note 2")

        merge(share1.id, share2.id)

        assert Share.query.one().note == "Note 2"
示例#4
0
def merge_shares():
    json = request.get_json()
    share1 = json.get("share1")
    share2 = json.get("share2")
    if not share1 or not share2:
        return jsonify(message='You need to supply share1 and share2'), 400
    merge(share1, share2)
    return jsonify(message='success')
示例#5
0
def merge_shares():
    json = request.get_json()
    share1 = json.get("share1")
    share2 = json.get("share2")
    if not share1 or not share2:
        return jsonify(message='You need to supply share1 and share2'), 400
    merge(share1, share2)
    return jsonify(message='success')
    def test_merge_keeps_station_other_way(self):
        station1 = StationFactory.create()

        share1 = ShareFactory.create(station=None)
        share2 = ShareFactory.create(station=station1)

        merge(share1.id, share2.id)

        assert Share.query.one().station == station1
示例#7
0
    def test_merge_keeps_station_other_way(self):
        station1 = StationFactory.create()

        share1 = ShareFactory.create(station=None)
        share2 = ShareFactory.create(station=station1)

        merge(share1.id, share2.id)

        assert Share.query.one().station == station1
    def test_merge_picks_first_station(self):
        station1 = StationFactory.create()
        station2 = StationFactory.create()

        share1 = ShareFactory.create(station=station1)
        share2 = ShareFactory.create(station=station2)

        merge(share1.id, share2.id)

        assert Share.query.one().station == station1
示例#9
0
    def test_merge_picks_first_station(self):
        station1 = StationFactory.create()
        station2 = StationFactory.create()

        share1 = ShareFactory.create(station=station1)
        share2 = ShareFactory.create(station=station2)

        merge(share1.id, share2.id)

        assert Share.query.one().station == station1
示例#10
0
    def test_merge_one_way(self):
        share1 = ShareFactory.create()
        share2 = ShareFactory.create()

        MemberFactory.create(share=share1)
        MemberFactory.create(share=share2)
        MemberFactory.create(share=share2)

        BetFactory.create(share=share1)
        BetFactory.create(share=share1)
        BetFactory.create(share=share2)

        assert Share.query.count() == 2
        assert Bet.query.count() == 3

        merge(share1.id, share2.id)

        updated_share = Share.query.one()

        assert Share.query.count() == 1
        assert len(updated_share.members) == 3
        assert len(updated_share.bets) == 3
        assert Member.query.count() == 3
        assert Bet.query.count() == 3