]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Fetch only enabled market
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 10 May 2018 14:33:25 +0000 (16:33 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 10 May 2018 14:33:25 +0000 (16:33 +0200)
main.py
tests/test_main.py

diff --git a/main.py b/main.py
index ee25182f24d54bd3326bd976d579c07c0ee896df..1c65e5644ca6ebbe855813da68bbef18ba995b16 100644 (file)
--- a/main.py
+++ b/main.py
@@ -71,9 +71,9 @@ def fetch_markets(user):
     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
index 1864c062af75fd1bd7d7c0eabca80127e6a2dc13..298e29e136ca1f4062a32af0e874d6aa331a4eaf 100644 (file)
@@ -325,7 +325,7 @@ class MainTest(WebMockTestCase):
         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)
 
@@ -333,7 +333,7 @@ class MainTest(WebMockTestCase):
         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)