def test_three_items(self, mock_fetch_price):
        item_ids = [554, 12345, 54321]
        expected = """fire rune: 15
pickle: 14321
frost dragon bones: 123k"""

        # Provide different return values for fetch_price() every time.
        fetch_price_retvals = {
            54321: ("frost dragon bones", "123k"),
            12345: ("pickle", "14321"),
            554: ("fire rune", "15"),
        }

        def fetch_price_side_effect(item_id):
            return fetch_price_retvals[item_id]

        mock_fetch_price.side_effect = fetch_price_side_effect

        self.assertEqual(multi_fetcher.fetch_prices(item_ids), expected)
 def test_no_items(self, mock_fetch_price):
     self.assertEqual(multi_fetcher.fetch_prices([]), "")
 def test_one_item_fire_rune(self, mock_fetch_price):
     item_ids = [554]
     expected = "fire rune: 15"
     mock_fetch_price.return_value = ("fire rune", "15")
     self.assertEqual(multi_fetcher.fetch_prices(item_ids), expected)
     mock_fetch_price.assert_called_once_with(554)
Ejemplo n.º 4
0
# Runescape Price Fetcher
# Author: Ryan Moyer

from __future__ import print_function

from multi_fetcher import fetch_prices

import argparse

parser = argparse.ArgumentParser(description='Grabs item ID.')
parser.add_argument('item_ids', metavar='ITEM_ID', type=int, nargs='+', help='the id for an item')
args = parser.parse_args()

print(fetch_prices(args.item_ids))