Example #1
0
 def test_trade_offer(self):
     ask = ob.create_ask(1, 2, next_year)
     ask["id"] = 1234
     bid = ob.create_ask(1, 1, next_year)
     trade = ob.trade_offer(ask, bid)
     assert_is_not_none(trade)
     assert_equal(trade["recipient"], 1234)
     assert_equal(trade["quantity"], 1)
     assert_equal(trade["trade-id"], ask["message-id"])
 def test_trade_offer(self):
     ask = ob.create_ask(1, 2, next_year)
     ask['id'] = 1234
     bid = ob.create_ask(1, 1, next_year)
     trade = ob.trade_offer(ask, bid)
     assert_is_not_none(trade)
     assert_equal(trade['recipient'], 1234)
     assert_equal(trade['quantity'], 1)
     assert_equal(trade['trade-id'], ask['message-id'])
Example #3
0
 def test_match_bid(self):
     own_bid = ob.create_bid(11, 1, next_year)
     their_ask = ob.create_ask(10, 1, next_year)
     their_ask["id"] = 1234
     matching_ask = ob.match_bid(own_bid)
     assert_is(matching_ask, their_ask)
Example #4
0
 def test_get_own_asks(self):
     ask = ob.create_ask(1, 1, next_year)
     asks = ob.get_own_asks()
     assert_equal(asks, [ask])
Example #5
0
 def test_get_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     offer = ob.get_offer(self.public_id, 0)
     assert_equal(ask, offer)
Example #6
0
 def test_match_incoming_ask_without_a_match(self):
     ob.create_bid(11, 1, next_year)
     their_ask = ob.create_ask(12, 1, next_year)
     their_ask["id"] = 1234
     matching_bid = ob.match_incoming_ask(their_ask)
     assert_is(matching_bid, None)
Example #7
0
 def test_remove_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     offer = ob.remove_offer(ask["id"], ask["message-id"])
     assert_is(offer, ask)
     assert_equal(ob.offers, [])
 def test_lowest_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     ob.create_ask(2, 1, next_year)
     lowest_offer = ob.lowest_offer(ob.offers)
     assert_equal(lowest_offer, ask)
 def test_remove_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     offer = ob.remove_offer(ask['id'], ask['message-id'])
     assert_is(offer, ask)
     assert_equal(ob.offers, [])
 def test_match_incoming_ask(self):
     own_bid = ob.create_bid(12, 1, next_year)
     their_ask = ob.create_ask(11, 1, next_year)
     their_ask['id'] = 1234
     matching_bid = ob.match_incoming_ask(their_ask)
     assert_is(matching_bid, own_bid)
 def test_match_incoming_ask_without_a_match(self):
     ob.create_bid(11, 1, next_year)
     their_ask = ob.create_ask(12, 1, next_year)
     their_ask['id'] = 1234
     matching_bid = ob.match_incoming_ask(their_ask)
     assert_is(matching_bid, None)
 def test_match_ask_without_a_match(self):
     own_ask = ob.create_ask(11, 1, next_year)
     their_bid = ob.create_bid(10, 1, next_year)
     their_bid['id'] = 1234
     matching_bid = ob.match_ask(own_ask)
     assert_is_none(matching_bid)
 def test_match_bid(self):
     own_bid = ob.create_bid(11, 1, next_year)
     their_ask = ob.create_ask(10, 1, next_year)
     their_ask['id'] = 1234
     matching_ask = ob.match_bid(own_bid)
     assert_is(matching_ask, their_ask)
 def test_get_own_asks(self):
     ask = ob.create_ask(1, 1, next_year)
     asks = ob.get_own_asks()
     assert_equal(asks, [ask])
Example #15
0
 def test_match_ask_without_a_match(self):
     own_ask = ob.create_ask(11, 1, next_year)
     their_bid = ob.create_bid(10, 1, next_year)
     their_bid["id"] = 1234
     matching_bid = ob.match_ask(own_ask)
     assert_is_none(matching_bid)
 def test_create_ask(self):
     ask = ob.create_ask(1, 1, now)
     assert_equal(ask['type'], 'ask')
     assert_equal(ask['price'], 1)
     assert_equal(ask['quantity'], 1)
     assert_equal(len(ob.offers), 1)
Example #17
0
 def test_match_incoming_ask(self):
     own_bid = ob.create_bid(12, 1, next_year)
     their_ask = ob.create_ask(11, 1, next_year)
     their_ask["id"] = 1234
     matching_bid = ob.match_incoming_ask(their_ask)
     assert_is(matching_bid, own_bid)
 def test_get_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     offer = ob.get_offer(self.public_id, 0)
     assert_equal(ask, offer)
Example #19
0
 def test_lowest_offer(self):
     ask = ob.create_ask(1, 1, next_year)
     ob.create_ask(2, 1, next_year)
     lowest_offer = ob.lowest_offer(ob.offers)
     assert_equal(lowest_offer, ask)
 def test_get_offer_wrong_message_id(self):
     ob.create_ask(1, 1, next_year)
     offer = ob.get_offer(self.public_id, 1)
     assert_is_none(offer, None)
Example #21
0
 def test_create_ask(self):
     ask = ob.create_ask(1, 1, now)
     assert_equal(ask["type"], "ask")
     assert_equal(ask["price"], 1)
     assert_equal(ask["quantity"], 1)
     assert_equal(len(ob.offers), 1)
Example #22
0
 def test_clean_offers(self):
     ob.create_ask(1, 1, last_year)
     mock_function = lambda *x: x
     ob.clean_offers(mock_function)()
     assert_equal(ob.offers, [])
Example #23
0
 def test_get_offer_wrong_message_id(self):
     ob.create_ask(1, 1, next_year)
     offer = ob.get_offer(self.public_id, 1)
     assert_is_none(offer, None)
 def test_clean_offers(self):
     ob.create_ask(1, 1, last_year)
     mock_function = lambda *x: x
     ob.clean_offers(mock_function)()
     assert_equal(ob.offers, [])