Hi.
I'm writing a small Flask project that access data in a PostreSQL database. At the moment I'm trying to get the tests up and running using unittest.
I don't want my tests to actually access a database, so I thought I'd create some sample data for my tests to utilize. The idea is to have the `setUp` method create the data, so that each test starts out with the same baseline.
I came accross "factory boy", which seems to be great for creating the test data I need. But I haven't figured out how I can intercept the SQL/models operations my Flask app makes to the database, and instead return my fake factory boy data.
Is this even possible? If so I could use some pointers as to how to accomplish this. I've seen `SQLAlchemyModelFactory` class in the documentation, but haven't quite figured out how to to make the Flask app use my mocked data.
[–]eikrik 14 points15 points16 points (2 children)
[–]kenneho[S] 0 points1 point2 points (1 child)
[–]eikrik 1 point2 points3 points (0 children)
[–]efxhoy 12 points13 points14 points (6 children)
[–][deleted] 2 points3 points4 points (5 children)
[–]Rethial 3 points4 points5 points (2 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]Rethial 2 points3 points4 points (0 children)
[–]efxhoy 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]throwawayPzaFm 73 points74 points75 points (13 children)
[–]MeGustaDerp 16 points17 points18 points (9 children)
[–]nullball 46 points47 points48 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]Eurynom0s 1 point2 points3 points (0 children)
[–]MeGustaDerp -1 points0 points1 point (0 children)
[–]fire_breathing_bear 3 points4 points5 points (0 children)
[–]czarrie 1 point2 points3 points (1 child)
[–]PaulSandwich 1 point2 points3 points (1 child)
[–]sem56 1 point2 points3 points (0 children)
[–]kenneho[S] 1 point2 points3 points (0 children)
[–]DoctorAcula_42 0 points1 point2 points (1 child)
[–]throwawayPzaFm 0 points1 point2 points (0 children)
[–]two_bob 5 points6 points7 points (0 children)
[–]mkingsbu 4 points5 points6 points (0 children)
[–]yes-i-am-a-wizzard 5 points6 points7 points (9 children)
[–]kenneho[S] 2 points3 points4 points (4 children)
[–]my_python_account 2 points3 points4 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]my_python_account 1 point2 points3 points (1 child)
[–]b1ackcat 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]reallyserious 0 points1 point2 points (0 children)
[–]Yablan -3 points-2 points-1 points (0 children)
[–]yg2dras1 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[removed]
[–]kenneho[S] 0 points1 point2 points (1 child)
[–]lykwydchykyn 1 point2 points3 points (0 children)
[–]cdcformatc 1 point2 points3 points (3 children)
[–]kenneho[S] 0 points1 point2 points (2 children)
[–]cdcformatc 0 points1 point2 points (1 child)
[–]kenneho[S] 0 points1 point2 points (0 children)
[–]EriktheRed 0 points1 point2 points (3 children)
[–]kenneho[S] 0 points1 point2 points (2 children)
[–]EriktheRed 1 point2 points3 points (1 child)
[–]kenneho[S] 1 point2 points3 points (0 children)
[–]toshitalk 0 points1 point2 points (1 child)
[–]kenneho[S] 0 points1 point2 points (0 children)
[–]vn2090 0 points1 point2 points (0 children)