cursor = dbs.psql.cursor()
if user is None:
- cursor.execute("SELECT id,config,user_id FROM market_configs")
+ cursor.execute("SELECT id,config,user_id FROM market_configs WHERE status='enabled'")
else:
- cursor.execute("SELECT id,config,user_id FROM market_configs WHERE user_id = %s", user)
+ cursor.execute("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", user)
for row in cursor:
yield row
with self.subTest(user=None):
rows = list(main.fetch_markets(None))
- cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs")
+ cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled'")
self.assertEqual(["row_1", "row_2"], rows)
with self.subTest(user=1):
rows = list(main.fetch_markets(1))
- cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE user_id = %s", 1)
+ cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", 1)
self.assertEqual(["row_1", "row_2"], rows)