コード例 #1
0
def test_create_case(couchdb, sequence):
    "Tries to create a case"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")
    assert c.caseid == "case-0"
    assert c.creator_name == "Noufal Ibrahim"
    assert c.creator_email == "*****@*****.**"
    assert c.creator_useragent == "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)"
    assert c.subject == "Testing"
    assert c.description == "This is a test request"
    assert c.assignee == "*****@*****.**"
    assert c.status == "new"
    assert c.type == "case"
    created_date = c.created
    current_date = datetime.datetime.utcnow()
    assert created_date.day == current_date.day
    assert created_date.month == current_date.month
    assert created_date.year == current_date.year
コード例 #2
0
ファイル: model.py プロジェクト: yzou/openlibrary
 def get_cases(self):
     """Returns all support cases filed by this user.
     """
     email = self.email
     username = self.username
     
     # XXX-Anand: very inefficient. Optimize it later.
     cases = support.Support().get_all_cases()
     cases = [c for c in cases if c.creator_email == email or c.creator_username == username]
     return cases
コード例 #3
0
def test_sequence_numbers(couchdb, sequence):
    "Creates a bunch of cases and checks their case numbers"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    for i in range(0, 10):
        c = s.create_case(
            creator_name="Noufal Ibrahim",
            creator_email="*****@*****.**",
            creator_useragent=
            "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
            subject="Testing",
            description="This is a test request",
            assignee="*****@*****.**")
        assert c.caseid == "case-%d" % i
コード例 #4
0
def test_history_entry(couchdb, sequence):
    "Test history entries upon creation of a new case"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")
    entry = c.history[0]
    assert entry.at == c.created
    assert entry.by == "Noufal Ibrahim"
    assert entry.text == "Case created"
コード例 #5
0
def test_get_all_cases(couchdb, sequence):
    "Try to create a bunch of cases and get them all back"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    for i in range(0, 10):
        c = s.create_case(
            creator_name="Noufal Ibrahim",
            creator_email="*****@*****.**",
            creator_useragent=
            "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
            subject="Testing",
            description="This is a test request",
            assignee="*****@*****.**")
    returned_caseids = sorted([x.caseid for x in s.get_all_cases()])
    expected_caseids = ["case-%s" % x for x in range(0, 10)]
    assert returned_caseids == expected_caseids
コード例 #6
0
def test_modification_date(couchdb, sequence):
    "Tests the last modified time"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")
    assert c.last_modified == c.created
    c.add_worklog_entry("*****@*****.**", "Test entry")
    c = s.get_case(0)
    assert c.last_modified == c.history[-1].at
コード例 #7
0
def test_readback(couchdb, sequence):
    "Test all ways of reading the case back"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")

    c0 = s.get_case("case-0")  #Full string id
    c1 = s.get_case(0)  #Numeric id
    c2 = s.get_case("0")  #Partial string id
    assert c0 == c1 == c2
    assert c0.caseid == "case-0"
コード例 #8
0
def test_change_status(couchdb, sequence):
    "Check the API to change case statuses"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")
    assert c.caseid == "case-0"
    assert c.status == "new"
    c.change_status("assigned", "*****@*****.**")
    c = s.get_case("case-0")
    assert c.status == "assigned"
    entry = c.history[-1]
    assert entry.by == "*****@*****.**"
    assert entry.text == "Case status changed to 'assigned'"
コード例 #9
0
def test_add_worklog_entry(couchdb, sequence):
    "Checks if we can add worklog entries"
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    c = s.create_case(
        creator_name="Noufal Ibrahim",
        creator_email="*****@*****.**",
        creator_useragent=
        "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.18) Gecko/20110323 Iceweasel/3.5.18 (like Firefox/3.5.18)",
        subject="Testing",
        description="This is a test request",
        assignee="*****@*****.**")
    assert c.caseid == "case-0"
    assert len(c.history) == 1
    c.add_worklog_entry("*****@*****.**", "Test entry")
    c = s.get_case(0)
    assert len(c.history) == 2
    entry = c.history[-1]
    assert entry.by == "*****@*****.**"
    assert entry.text == "Test entry"
コード例 #10
0
def setup():
    global support_db
    try:
        support_db = S.Support()
    except S.DatabaseConnectionError:
        support_db = None
コード例 #11
0
def setup():
    global support_db
    support_db = S.Support()
コード例 #12
0
def test_nonexistentcase(couchdb):
    from openlibrary.core import support
    s = support.Support(db=couchdb)
    py.test.raises(support.InvalidCase, s.get_case, 12345)