示例#1
0
def test_item_should_delete_item(delete_item, get_items, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    delete_item.return_value = {'id': '1', 'name': 'Test Item 01'}
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    # Act
    item = item.delete()

    # Assert
    ok_(item != None)
    eq_(item.name, 'Test Item 01')
示例#2
0
def test_item_should_move_item_to_group(move_item_to_group, get_items, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    move_item_to_group.return_value = {'id': '1', 'name': 'Test Item 01'}
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    # Act
    item = item.move_to_group('group_01')

    # Assert
    ok_(item != None)
    eq_(item.name, 'Test Item 01')
示例#3
0
def test_item_should_add_a_subitem(create_subitem, get_items, get_me):

    # Arrange
    id = '2'
    name = 'Test Subitem 01'
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    create_subitem.return_value = {'id': id, 'name': name}
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    # Act
    subitem = item.create_subitem(name)

    # Assert
    ok_(subitem != None)
    eq_(subitem.id, id)
    eq_(subitem.name, name)
示例#4
0
def test_item_should_change_multiple_column_values_with_dictionary(
        change_multiple_column_value, get_board, get_items, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    get_board.return_value = en.Board(**{'id': '1', 'name': 'Test Board 1'})
    change_multiple_column_value.return_value = {
        'id': '1',
        'name': 'Test Item 01'
    }
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    # Act
    item = item.change_multiple_column_values(
        {'text_column_01': 'Hello, world!'})

    # Assert
    ok_(item != None)
    eq_(item.name, 'Test Item 01')
示例#5
0
def test_item_should_get_column_values_for_status_column(
        get_columns, get_board, get_items, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 1'}]
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    get_board.return_value = en.Board(**{'id': '1', 'name': 'Test Board 1'})
    get_columns.return_value = [
        en.Column({
            'id': 'status_column_01',
            'type': 'color',
            'settings_str': json.dumps({'labels': {
                '1': 'Test'
            }})
        })
    ]
    get_items.return_value = [{
        'id':
        '1',
        'column_values': [{
            'id': 'status_column_01',
            'title': 'Status Column 01',
            'value': json.dumps({'index': 1})
        }]
    }]

    # Act
    column_values = item.get_column_values()

    # Assert
    ok_(column_values != None)
    eq_(len(column_values), 1)
    eq_(column_values[0].title, 'Status Column 01')
    eq_(column_values[0].index, 1)
    eq_(column_values[0].text, 'Test')
示例#6
0
def test_item_should_fail_to_delete_update(get_items, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]
    get_items.return_value = [{
        'id':
        '1',
        'updates': [{
            'id': '2',
            'item_id': '1',
            'creator_id': '1',
            'replies': [{
                'id': '3',
                'creator_id': '1'
            }]
        }]
    }]

    # Act
    item.delete_update(5)
示例#7
0
def test_item_should_delete_update(delete_update, get_items, get_me):

    # Arrange
    id = '2'
    item_id = '1'
    creator_id = '1'
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{'id': '1', 'name': 'Test Item 01'}]
    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]
    get_items.return_value = [{
        'id':
        '1',
        'updates': [{
            'id': id,
            'item_id': item_id,
            'creator_id': creator_id,
            'replies': [{
                'id': '3',
                'creator_id': '1'
            }]
        }]
    }]
    delete_update.return_value = {
        'id': id,
        'item_id': item_id,
        'creator_id': creator_id
    }

    # Act
    update = item.delete_update(id)

    # Assert
    ok_(update)
    eq_(update.id, id)
    eq_(update.item_id, item_id)
    eq_(update.creator_id, creator_id)
示例#8
0
def test_item_should_get_files(get_items, get_me):

    # Arrange
    asset_id = '12345'
    name = '33.jpg'
    url = 'https://test.monday.com/12345/33.jpg'
    get_me.return_value = GET_ME_RETURN_VALUE
    get_items.return_value = [{
        'id': '1',
        'name': 'Test Item 01',
        'board': {
            'id': '1'
        }
    }]

    client = MondayClient(USERNAME, '', '')
    item = client.get_items()[0]

    get_items.return_value = [{
        'id':
        '1',
        'assets': [{
            'id': asset_id,
            'name': name,
            'url': url
        }]
    }]

    # Act
    assets = item.get_files()

    # Assert
    ok_(assets != None)
    eq_(assets[0].id, '12345')
    eq_(assets[0].name, '33.jpg')
    eq_(assets[0].url, 'https://test.monday.com/12345/33.jpg')