Esempio n. 1
0
    def testBuyWithNewUsers(self):
        uh = [id_generator(), id_generator()]
        for h in uh:
            assert self.session.query(User).filter(User.handle == h).one_or_none() is None

        self.friendBizAPI.buy(uh[0], uh[1])

        self.session.close()
        self.session = self.dbSessionMaker()

        # should now both exist
        u = [self.friendBizAPI.getUserByHandle(h) for h in uh]

        for i in u:
            assert i is not None

        assert u[0].balance == self.config['startingBalance'] - self.config['startingPrice']
Esempio n. 2
0
    def testGetOrCreate(self):

        handle = id_generator()
        u1 = self.friendBizAPI.getOrCreateUserByHandle(handle, self.session)
        self.session.commit()
        assert u1.id

        # repeating should get same ID
        u2 = self.friendBizAPI.getOrCreateUserByHandle(handle, self.session)
        assert u2.id == u1.id