Changeset - f227593655ba
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-03-25 19:24:32
brettcsmith@brettcsmith.org
tests: New RT client classes start with seeded ticket data.

This reduces the amount of setup many tests need to do before they modify
the ticket data.
1 file changed with 9 insertions and 11 deletions:
0 comments (0 inline, 0 general)
tests/test_rtutil.py
Show inline comments
...
 
@@ -45,3 +45,3 @@ def new_client():
 
    class RTClient(testutil.RTClient):
 
        TICKET_DATA = {'1': [], '2': []}
 
        TICKET_DATA = testutil.RTClient.TICKET_DATA.copy()
 
    return RTClient()
...
 
@@ -55,3 +55,3 @@ def test_url(rt, ticket_id, attachment_id, expected):
 
@pytest.mark.parametrize('attachment_id', [
 
    3,
 
    13,
 
    None,
...
 
@@ -59,3 +59,2 @@ def test_url(rt, ticket_id, attachment_id, expected):
 
def test_url_caches(new_client, attachment_id):
 
    new_client.TICKET_DATA['1'].append(('3', '(Unnamed)', 'text/plain', '3.0k'))
 
    if attachment_id is None:
...
 
@@ -63,8 +62,8 @@ def test_url_caches(new_client, attachment_id):
 
    else:
 
        fragment = '#txn-3'
 
    expected = '{}Ticket/Display.html?id=1{}'.format(DEFAULT_RT_URL, fragment)
 
        fragment = '#txn-11'
 
    expected = '{}Ticket/Display.html?id=2{}'.format(DEFAULT_RT_URL, fragment)
 
    rt = rtutil.RT(new_client)
 
    assert rt.url(1, attachment_id) == expected
 
    assert rt.url(2, attachment_id) == expected
 
    new_client.TICKET_DATA.clear()
 
    assert rt.url(1, attachment_id) == expected
 
    assert rt.url(2, attachment_id) == expected
 

	
...
 
@@ -77,3 +76,3 @@ def test_url_caches(new_client, attachment_id):
 
def test_url_default_filename(new_client, mimetype, extension):
 
    new_client.TICKET_DATA['1'].append(('9', '(Unnamed)', mimetype, '50.5k'))
 
    new_client.TICKET_DATA['1'] = [('9', '(Unnamed)', mimetype, '50.5k')]
 
    rt = rtutil.RT(new_client)
...
 
@@ -88,3 +87,2 @@ def test_exists(rt, ticket_id, attachment_id, expected):
 
def test_exists_caches(new_client):
 
    new_client.TICKET_DATA['1'].append(('3', '(Unnamed)', 'text/plain', '3.0k'))
 
    rt = rtutil.RT(new_client)
...
 
@@ -92,3 +90,3 @@ def test_exists_caches(new_client):
 
    assert rt.exists(2)
 
    assert not rt.exists(1, 9)
 
    assert not rt.exists(1, 99)
 
    assert not rt.exists(9)
...
 
@@ -97,3 +95,3 @@ def test_exists_caches(new_client):
 
    assert rt.exists(2)
 
    assert not rt.exists(1, 9)
 
    assert not rt.exists(1, 99)
 
    assert not rt.exists(9)
0 comments (0 inline, 0 general)