def create_members(): member1 = models.Members("Mohammed", 20) member2 = models.Members("Mohammed", 22) member3 = models.Members("Abdo", 25) print(member1) print(member2) print(member3) print("=" * 30) return member1, member2, member3
def create_members(): member1 = models.Members("Majd", 36) member2 = models.Members("Rida", 28) member3 = models.Members("Manhal", 29) member4 = models.Members("Majd", 50) print(member1) print(member2) print(member3) print(member4) print("=" * 30) return member1, member2, member3, member4
def update_should_modify_object(member_store, member3): member3_copy = models.Members(member3.name, member3.age) member3_copy.id = 3 if member3_copy is not member3: print("member3 and member3_copy are not the same !") print(member3_copy) member3_copy.name = "john" member_store.update(member3_copy) print(member_store.get_by_id(member3.id))
from app import models, db dummy_members = [ models.Members(name="Mohammed", age=20), models.Members(name="Mohammed", age=22), models.Members(name="Abdo", age=25), ] dummy_posts = [ models.Post(title="Agriculture", content="Agriculture is amazing", member_id=1), models.Post(title="Engineering", content="I love engineering", member_id=1), models.Post(title="Medicine", content="Medicine is great", member_id=2), models.Post(title="Architecture", content="Spectacular art", member_id=2), models.Post(title="Astronomy", content="Space is awesome", member_id=2), models.Post(title="Geology", content="Earth is our friend", member_id=3), models.Post(title="ComputerSci", content="Our passion", member_id=3), models.Post(title="Algorithms", content="Yeah, more of that", member_id=3), models.Post(title="Operating Systems", content="Ewww", member_id=3), ] def seed_stores(member_store, post_store): db.drop_all() db.create_all() for member in dummy_members: member_store.add(member)
from app import models import random dummy_members = [ models.Members("Mohammed", 20,), models.Members("Yassin", 22,), models.Members("Abdo", 25,), ] dummy_posts = [ models.Post("Agriculture", "Agriculture is amazing", dummy_members[0].id), models.Post("Engineering", "I love engineering", dummy_members[0].id), models.Post("Medicine", "Medicine is great", dummy_members[1].id), models.Post("Architecture", "Spectacular art", dummy_members[1].id), models.Post("Astronomy", "Space is awesome", dummy_members[1].id), models.Post("Geology", "Earth is our friend", dummy_members[2].id), models.Post("ComputerSci", "Our passion", dummy_members[2].id,), models.Post("Algorithms", "Yeah, more of that", dummy_members[2].id), models.Post("Operating Systems", "Ewww", dummy_members[2].id), ] def seed_stores(member_store, post_store): for member in dummy_members: member_store.add(member) for post in dummy_posts: post_store.add(post)