コード例 #1
0
    def setUp(self):
        DatabaseTest.setUp(self)
        self._user_fixture()
        self.command = commands.QUOTECommand()

        # Set the quote client to a dummy that returns predictable results
        client._QUOTE_CLIENT = client.DummyQuoteClient({'ABAB': Money(23, 45)})
コード例 #2
0
 def setUp(self):
     DatabaseTest.setUp(self)
     self._user_fixture()
     self.transaction = Transaction(username='******', stock_symbol='ABAB',
         operation='BUY', committed=False, quantity=2,
         stock_value=Money(10, 40))
     self.add_all(self.transaction)
コード例 #3
0
    def setUp(self):
        DatabaseTest.setUp(self)
        self._user_fixture()

        # Uncommitted transaction record for user 2 ("user1")
        self.trans = Transaction(username='******', stock_symbol='ABAB',
            operation='SELL', committed=False, quantity=2,
            stock_value=Money(10, 40))

        self.add_all(self.trans)
コード例 #4
0
    def setUp(self):
        DatabaseTest.setUp(self)
        self.command = commands.CANCEL_SET_SELLCommand()

        self._user_fixture()

        # inactive transaction record for rich_user
        self.trans = Trigger(username='******', stock_symbol='ABAB',
            operation='SELL', state=Trigger.State.INACTIVE, amount=Money(0, 0))

        self.add_all(self.trans)
コード例 #5
0
    def setUp(self):
        DatabaseTest.setUp(self)
        self.command = commands.CANCEL_SET_BUYCommand()

        self._user_fixture()

        # active BUY trigger for rich_user
        self.trans = Trigger(username='******', stock_symbol='ABAB',
            operation='BUY', state=Trigger.State.INACTIVE)

        self.add_all(self.trans)
コード例 #6
0
    def setUp(self):
        # set up the database as inherited from DatabaseTest
        DatabaseTest.setUp(self)
        # call user fixture to populate the database (from DatabaseTest)
        self._user_fixture()
        #associate the sell command
        self.command = commands.SET_SELL_AMOUNTCommand()

        self.add_all(
            # Give 'rich_user' 10 units of 'ABAB' stock
            StockPurchase(username='******', stock_symbol='ABAB', quantity=10),
        )
コード例 #7
0
    def setUp(self):
        DatabaseTest.setUp(self)
        self._user_fixture()

        # Uncommitted transaction record for user 2 ("user1")
        self.trans = Transaction(username='******', stock_symbol='ABAB',
            operation='SELL', committed=False, quantity=2,
            stock_value=Money(10, 40))

        # Existing stock owned by user 2
        self.stock = StockPurchase(username='******', stock_symbol='ABAB', quantity=10)

        self.session.add_all([self.trans, self.stock])
        self.session.commit()
コード例 #8
0
    def setUp(self):
        # set up the database as inherited from DatabaseTest
        DatabaseTest.setUp(self)
        # call user fixture to populate the database (from DatabaseTest)
        self._user_fixture()
        #associate the sell command
        self.command = commands.SELLCommand()

        # Set the quote client to a dummy that returns predictable results
        client._QUOTE_CLIENT = client.DummyQuoteClient({
            'ABAB': Money(23, 45),
            'BBBB': Money(85, 39),
        })

        self.add_all(
            # Give 'rich_user' 10 units of 'ABAB' stock
            StockPurchase(username='******', stock_symbol='ABAB', quantity=10),
        )
コード例 #9
0
    def setUp(self):
        # set up the database as inherited from DatabaseTest
        DatabaseTest.setUp(self)

        #associate the sell command
        self.command = commands.DISPLAY_SUMMARYCommand()

        self.user = User(username='******', password='', 
            account_balance=Money(10, 20), reserve_balance=Money(30, 40))
        self.add_all(
            self.user,
            Transaction(user=self.user, stock_symbol='AAAA', operation='BUY',
                committed=False, quantity=1, stock_value=Money(10, 54)),
            Transaction(user=self.user, stock_symbol='BBBB', operation='SELL',
                committed=True, quantity=1, stock_value=Money(10, 54)),
            Trigger(user=self.user, amount=Money(10, 54),
                    operation='BUY', stock_symbol='AAAA', state=Trigger.State.INACTIVE),
            Trigger(user=self.user, amount=Money(10, 54),
                    operation='BUY', stock_symbol='AAAA', state=Trigger.State.RUNNING),
            StockPurchase(user=self.user, stock_symbol='ABAB', quantity=10),
            StockPurchase(user=self.user, stock_symbol='CDCD', quantity=20),
        )
コード例 #10
0
 def setUp(self):
     DatabaseTest.setUp(self)
     self._user_fixture()
     self.command = commands.ADDCommand()
コード例 #11
0
 def setUp(self):
     DatabaseTest.setUp(self)
     self._user_fixture()
     self.command = commands.SET_BUY_AMOUNTCommand()