def test_save_insert(self): tester = Position(account_pk = jimid, total_quantity = 10, ticker = "pton") tester.save() result = Position.all() self.assertEqual(len(result),2, "len =2 b/c seeded 1 pos and added another") self.assertEqual(result[0].ticker,"aapl","all func populates attributes, checking first for row[0] / pk1" ) self.assertEqual(result[1].ticker,"pton","all func populates attributes, checking email for row[1] / pk2" )
def test_all(self): result = Position.all() self.assertEqual(len(result), 1, "all func returns list with correct number of elements 1 is from seed") self.assertIsInstance(result[0], Position, "all func returns position object") self.assertEqual(result[0].total_quantity, 5, "all func populates attributes")
def test_save_update(self): result = Position.from_pk(jimid) result.total_quantity = 12 result.save() result = Position.all() self.assertEqual(result[0].total_quantity,12,"all func populates attributes, checking updated first for row[0] / pk1" )