예제 #1
0
파일: main.py 프로젝트: sariera/forums
def stores_should_be_similar():
    member_store1 = store.MemberStore()
    member_store2 = store.MemberStore()
    if member_store1.get_all() is member_store2.get_all():
        print("Same stores elements !")
예제 #2
0
import models
import store

m1 = models.Member("zoheer",33)
m2 = models.Member("ahmad" ,15)

p1 = models.Post("python","Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.")
p2 = models.Post("html","Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications. With Cascading Style Sheets (CSS) and JavaScript, it forms a triad of cornerstone technologies for the World Wide Web.[4] Web browsers receive HTML documents from a web server or from local storage and render them into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.")
p3 = models.Post("CSS","Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language.[1] Although most often used to set the visual style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any XML document, including plain XML, SVG and XUL, and is applicable to rendering in speech, or on other media. Along with HTML and JavaScript, CSS is a cornerstone technology used by most websites to create visually engaging webpages, user interfaces for web applications, and user interfaces for many mobile applications")

msotre = store.MemberStore()
msotre.add(m1)
msotre.add(m2)
print msotre.get_by_id(2)
print msotre.entity_exists(2)
msotre.delete(2)
msotre.get_all()

pstore = store.PostStore()
pstore.add (p1)
pstore.add (p2)
pstore.add (p3)
print pstore.entity_exists(1)
print pstore.get_by_id(1)
pstore.get_all()
예제 #3
0
파일: main.py 프로젝트: sariera/forums

def store_should_get_top_two(member_store, post_store):
    top_two_members = member_store.get_top_two(post_store.get_all())

    for member_with_posts in top_two_members:
        print "{} has posts:".format(member_with_posts)
        for post in member_with_posts.posts:
            print "\t{}".format(post)

members_instances = create_members()


member1, member2, member3 = members_instances

member_store = store.MemberStore()

store_should_add_members(members_instances, member_store)

stores_should_be_similar()

print_all_members(member_store)

get_by_id_should_retrieve_same_object(member_store, member2)

update_should_modify_object(member_store, member3)

catch_exception_when_deleting()

print_all_members(member_store)