Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_logout(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
self.assertTrue(client.is_session_alive())
client.logout()
def test_get_trade_offers_summary(self):
client = SteamClient(self.credentials.api_key)
summary = client.get_trade_offers_summary()
self.assertIsNotNone(summary)
def test_get_price_to_many_requests(self):
def request_loop() -> None:
item = 'M4A1-S | Cyrex (Factory New)'
for _ in range(21):
client.market.fetch_price(item, GameOptions.CS)
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
self.assertRaises(TooManyRequests, request_loop)
def test_create_and_remove_sell_listing(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
game = GameOptions.DOTA2
inventory = client.get_my_inventory(game)
asset_id_to_sell = None
for asset_id, item in inventory.items():
if item.get("marketable") == 1:
asset_id_to_sell = asset_id
break
self.assertIsNotNone(asset_id_to_sell, "You need at least 1 marketable item to pass this test")
response = client.market.create_sell_order(asset_id_to_sell, game, "10000")
self.assertTrue(response["success"])
sell_listings = client.market.get_my_market_listings()["sell_listings"]
listing_to_cancel = None
for listing in sell_listings.values():
if listing["description"]["id"] == asset_id_to_sell:
listing_to_cancel = listing["listing_id"]
def test_get_my_inventory(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
inventory = client.get_my_inventory(GameOptions.CS)
self.assertIsNotNone(inventory)
def test_client_with_statement(self):
with SteamClient(self.credentials.api_key, self.credentials.login,
self.credentials.password, self.steam_guard_file) as client:
self.assertTrue(client.is_session_alive())
def test_accept_trade_offer_without_login(self):
client = SteamClient(self.credentials.api_key)
self.assertRaises(LoginRequired, client.accept_trade_offer, 'id')
def test_accept_trade_offer(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
trade_offer_id = '1451378159'
response_dict = client.accept_trade_offer(trade_offer_id)
self.assertIsNotNone(response_dict)
def test_get_price_history(self):
with SteamClient(self.credentials.api_key, self.credentials.login,
self.credentials.password, self.steam_guard_file) as client:
item = 'M4A1-S | Cyrex (Factory New)'
response = client.market.fetch_price_history(item, GameOptions.CS)
self.assertTrue(response['success'])
self.assertIn('prices', response)
def test_get_trade_offer(self):
client = SteamClient(self.credentials.api_key)
trade_offer_id = '1442685162'
offer = client.get_trade_offer(trade_offer_id)
self.assertIsNotNone(offer)