Beispiel #1
0
def test_get_object_type():
    """Test get object type"""

    obj = Lugito()

    with open(FAKE_REQ_DATA, 'r') as f:
        obj.request_data = json.load(f)

    assert(obj.get_object_type() == 'DREV')
Beispiel #2
0
def test_is_new_object_true():
    """Test is new task - true"""

    obj = Lugito()

    with open(FAKE_REQ_DATA, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_TRANSACTION_NEW_OBJECT, 'r') as f:
        obj.transaction = json.load(f)

    assert (obj.is_new_object())
Beispiel #3
0
def test_is_new_object_false():
    """Test is new task - false"""

    obj = Lugito()

    with open(FAKE_REQ_DATA, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_TRANSACTION, 'r') as f:
        obj.transaction = json.load(f)

    assert (not obj.is_new_object())
Beispiel #4
0
def test_is_edited_comment():
    """Test checking for edited comment"""

    obj = Lugito()

    with open(FAKE_REQ_EDITED_COMMENT, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_EDITED_COMMENT, 'r') as f:
        obj.transaction = json.load(f)

    new_comment, edited, _id = obj.is_comment()

    assert(not new_comment)
    assert(edited)
    assert(_id == 157)
Beispiel #5
0
def test_is_new_comment():
    """Test checking for new  - using transaction search"""

    obj = Lugito()

    with open(FAKE_REQ_NEW_COMMENT, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_NEW_COMMENT, 'r') as f:
        obj.transaction = json.load(f)

    new_comment, edited, _id = obj.is_comment()

    assert(new_comment)
    assert(not edited)
    assert(_id == 133)
Beispiel #6
0
def test_author_fullname_error():
    """Test unable to get the author name"""

    obj = Lugito()

    with open(FAKE_REQ_DATA, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_TRANSACTION, 'r') as f:
        obj.transaction = json.load(f)

    obj.phab = MagicMock()
    obj.phab.phid.query = MagicMock(side_effect=http.client.HTTPException)

    author_name = obj.get_author_fullname()
    assert(author_name is None)
Beispiel #7
0
def test_author_fullname():
    """Test get the author name"""

    obj = Lugito()

    with open(FAKE_REQ_DATA, 'r') as f:
        obj.request_data = json.load(f)

    with open(FAKE_TRANSACTION, 'r') as f:
        obj.transaction = json.load(f)

    obj.phab = MagicMock()
    obj.phab.phid.query = MagicMock(return_value={
        'PHID-USER-5cmhaqtkggymhvbyqdcv':{
            'fullName': 'AuthorName',
            },
        }
    )

    author_name = obj.get_author_fullname()
    assert(author_name == 'AuthorName')