Пример #1
0
def remove_forum(forum_name):
    """Remove a community and make sure it is gone"""

    # Normally we don't need to do this, as make_community internally
    # does a delete before adding.

    global_dict, local_dict = namespaces.get_twill_glocals()

    # Go to the forum, see if it exists.  If not, log a message.
    # If so, delete it.
    commands.go("/offices/forums/" + forum_name)
    br = get_browser()
    status = br.get_code()
    if status != 200:
        msg = "Community %s not returning 200, must exist"
        dump(msg % forum_name)
    else:
        url = "/offices/forums/%s/delete.html?confirm=1" % forum_name
        commands.go(url)
        commands.title("Forums")
Пример #2
0
def make_forum(forum_name=test_name, title=None):
    """Make a forum, deleting first if the forum exists"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # Append "-testcase" to the community name, so we can spot later
    # which were created by Twillif community_name == test_name:
    if forum_name == test_name:
        forum_name = global_dict.get('forum_name',
                                         test_name + '-forum-testcase')
        global_dict['test_name'] = test_name
        global_dict['forum_name'] = forum_name

    # Echo to screen
    dump("Forum is %s" % forum_name)

    if title is None:
        title = forum_name

    # Check to see if we have that community, if so, delete it.
    commands.go("/offices/forums/%s" % (forum_name))
    br = get_browser()
    status = br.get_code()
    if status != 404:
        # The community shouldn't exist, and so we should get 404
        # looking for it.  If no 404, then it exists and we should
        # delete it.
        # Echo to screen
        dump("Deleted old version of Forum: %s " % (forum_name))
        url = "/offices/forums/%s/delete.html?confirm=1" % forum_name
        commands.go(url)
        commands.title("Forums")
    else:
        dump("Didn't delete old version of Forum: %s " % (forum_name))
    # Now, make the community and make sure it exists
    commands.go("/offices/forums/add_forum.html")
    commands.fv("save", "title", title)
    desc = "Test forum created for Twill test case named '%s'"
    commands.fv("save", "description", desc % forum_name)
    commands.submit()
    commands.find("Add Forum Topic")