def test_menu_option_9_1_match(self, mock_open, mock_stdout, *args): app = PyMkmApp(self.config) with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"import_from_csv:")
def test_menu_option_6(self, mock_stdout, *args): # clean_purchased_from_wantslists app = PyMkmApp(self.config) app.start() print(mock_stdout.getvalue()) self.assertRegex(mock_stdout.getvalue(), r"This will show items in your ")
def test_stock_update(self, mock_stdin, mock_stdout, *args): self.assertEqual(True, True) app = PyMkmApp() app.start(self.parsed_args) out = mock_stdout.getvalue() self.assertRegex(out, r"API calls used today")
def main(): parser = argparse.ArgumentParser( description="pymkm command line interface.") parser.add_argument("--version", action="version", version=__version__) parser.add_argument( "--update_stock", action="store_true", help="Update stock prices. Use --partial if needed.", ) parser.add_argument( "--partial", metavar="<number>", type=int, default=0, help="Used for partial updates of for example stock.", ) parser.add_argument( "--price_check_wantslist", metavar="<wantslist name>", type=str, help="Run the Track price data to csv option.", ) parser.add_argument( "--cached", type=bool, default=False, help="Use cached values if available (defaults to False).", ) args = parser.parse_args() app = PyMkmApp() app.start(args)
def test_menu_option_5(self, mock_stdout, *args): # show_top_expensive_articles_in_stock app = PyMkmApp(self.config) app.start() text = mock_stdout.getvalue() self.assertRegex(mock_stdout.getvalue(), r"Top 20 most expensive articles in stock:")
def test_menu_option_8(self, *args): # clear_entire_stock app = PyMkmApp(self.config) with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"clear_entire_stock")
def test_menu_option_4(self, mock_stdout, *args): # find_deals_from_user app = PyMkmApp(self.config) with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"find_deals_from_user")
def test_menu_option_2(self, mock_open, mock_stdout, *args): # update_product_to_trend app = PyMkmApp(self.config) with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"update_product_to_trend")
def test_menu_option_3(self, mock_stdout, *args): # list_competition_for_product app = PyMkmApp(self.config) with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"list_competition_for_product")
def test_menu_option_7(self, mock_stdout, *args): # show_account_info app = PyMkmApp(self.config) # app.start() # self.assertRegex(mock_stdout.getvalue(), r"{'account':") with self.assertLogs(level="DEBUG") as cm: app.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"show_account_info")
def test_report(self, mock_post, *args): app = PyMkmApp(self.config) with self.assertLogs(level="ERROR") as cm: self.patcher.stop() app.report("testcommand") self.patcher.start() log_record = cm.records[len(cm.records) - 1] self.assertRegex(log_record.message, r"Connection error to stats server.")
def test_get_price_for_product(self, mock_response, *args): self.api = PyMkmApi(self.config) app = PyMkmApp(self.config) fake_product = app.get_stock_as_array(self.api)[0] price = app.get_price_for_product( fake_product["idProduct"], fake_product["product"]["rarity"], fake_product["condition"], fake_product["isFoil"], fake_product["isPlayset"], api=self.api, ) self.assertEqual(price, 3.0)
def test_select_from_list_of_articles(self, *args): app = PyMkmApp(self.config) article = app.select_from_list_of_articles(TestCommon.get_stock_result) self.assertEqual(article["idArticle"], 410480091)
def test_select_from_list_of_wantslists(self, *args): app = PyMkmApp(self.config) list = app.select_from_list_of_wantslists( TestCommon.cardmarket_get_wantslists) self.assertEqual(list["idWantslist"], 2789285)
def test_check_latest_version(self, *args): app = PyMkmApp(self.config) self.assertIsNone(app.check_latest_version())
def test_main_menu(self, mock_input, mock_stdout, *args): app = PyMkmApp(self.config) app.start() self.assertRegex(mock_stdout.getvalue(), r"╭─── PyMKM")
def test_get_rounding_limit_for_rarity(self, mock_account): app = PyMkmApp(self.config) self.assertEqual(app.get_rounding_limit_for_rarity("rare", "1"), 1.0) self.assertEqual( app.get_rounding_limit_for_rarity("time shifted", "1"), 0.25) self.assertEqual(app.get_rounding_limit_for_rarity("XX", "1"), 0.25)
def test_get_discount_for_condition(self, mock_account): app = PyMkmApp(self.config) self.assertEqual(app.get_discount_for_condition("MT"), 1.5) self.assertEqual(app.get_discount_for_condition("LP"), 0.6) with self.assertRaises(KeyError): app.get_discount_for_condition("XX")
def test_menu_option_7(self, mock_stdout, *args): # show_account_info app = PyMkmApp(self.config) app.start() print(mock_stdout.getvalue()) self.assertRegex(mock_stdout.getvalue(), r"{'account':")
def main(): app = PyMkmApp() app.start()
def test_app_starts(self, mock_input, mock_stdout, *args): self.assertEqual(True, True) app = PyMkmApp() app.start(self.parsed_args) self.assertRegex(mock_stdout.getvalue(), r"╭─── PyMKM")