예제 #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)