コード例 #1
0
def test_board_should_fail_to_retrieve_a_group_from_too_many_parameters(create_board, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    board.get_group(id='group1', title='Group 1')
コード例 #2
0
def test_should_fail_from_too_many_parameters(create_board, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    board.get_column_value(id='text_column_01', title='Text Column 01')
コード例 #3
0
def test_should_fail_to_create_webhook_from_invalid_event(create_board, get_me):

    # Arrange
    board_id = '1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}

    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act
    board.create_webhook('http://test.webhook.com/webhook/test', WebhookEventType.create_item, columnId='test_1')
コード例 #4
0
def test_should_create_a_new_group(create_group, create_board, get_me):

    # Arrange
    title = 'Group 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    create_group.return_value = {'id': '1', 'title': title}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    group = board.add_group(title)

    # Assert
    ok_(group != None)
    eq_(group.title, title)
コード例 #5
0
def test_should_get_column_value_by_title(get_columns, create_board, get_me):

    # Arrange
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    get_columns.return_value = [en.Column({'id': 'text_column_01', 'title': 'Text Column 01', 'type': 'text'})]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    column_value = board.get_column_value(title='Text Column 01')

    # Assert
    ok_(column_value != None)
    eq_(column_value.id, 'text_column_01')
    eq_(column_value.title, 'Text Column 01')
    eq_(type(column_value), cv.TextValue)
コード例 #6
0
def test_should_create_an_item(create_item, create_board, get_me):

    # Arrange
    board_id = '1'
    name = 'Item 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    create_item.return_value = {'id': '1', 'name': name}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    item = board.add_item(name)

    # Assert
    ok_(item != None)
    eq_(item.name, name)
コード例 #7
0
def test_should_retrieve_a_list_of_groups(get_boards, create_board, get_me):

    # Arrange
    title = 'Group 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    get_boards.return_value = [{'id': '1', 'groups': [{'id': '1', 'title': title}]}]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    groups = board.get_groups()

    # Assert
    ok_(groups != None)
    eq_(len(groups), 1)
    eq_(groups[0].title, title)
コード例 #8
0
def test_should_retrieve_a_list_of_items(get_boards, create_board, get_me):

    # Arrange
    board_id = '1'
    name = 'Item 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    get_boards.return_value = [{'id': '1', 'items': [{'id': '1', 'name': name}]}]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    items = board.get_items()

    # Assert
    ok_(items != None)
    eq_(len(items), 1)
    eq_(items[0].name, name)
コード例 #9
0
def test_should_add_new_column(create_column, create_board, get_me):

    # Arrange
    title = 'Text Column 1'
    column_type = ColumnType.text
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    create_column.return_value = {'id': '1', 'title': title, 'type': column_type.name}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    column = board.add_column(title, column_type)

    # Assert
    ok_(column != None)
    eq_(column.title, title)
    eq_(column.column_type, column_type)
コード例 #10
0
def test_board_should_create_an_item_with_dict_column_values(create_item, create_board, get_me):

    # Arrange
    board_id = '3'
    name = 'Item 3'
    group_id = 'group2'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    create_item.return_value = {'id': '3', 'name': name}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    item = board.add_item(name, group_id=group_id, column_values={'status':{'index': 0}})

    # Assert
    ok_(item != None)
    eq_(item.name, name)
コード例 #11
0
def test_should_retrieve_a_group_by_title(get_boards, create_board, get_me):

    # Arrange
    id = '1'
    title = 'Group 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    get_boards.return_value = [{'id': '1', 'groups': [{'id': id, 'title': title}]}]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    group = board.get_group(title=title)

    # Assert
    ok_(group != None)
    eq_(group.id, id)
    eq_(group.title, title)
コード例 #12
0
def test_should_retrieve_a_list_of_items_by_column_value(get_items_by_column_values, create_board, get_me):

    # Arrange
    board_id = '1'
    name = 'Item 1'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    get_items_by_column_values.return_value = [{'id': '1', 'name': name}]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    column_value = cv.create_column_value(ColumnType.text, id='text_column_01', title='Text Column 01', text='Some Value', value=json.dumps('Some Value'))
    items = board.get_items_by_column_values(column_value)

    # Assert
    ok_(items != None)
    eq_(len(items), 1)
    eq_(items[0].name, name)
コード例 #13
0
def test_should_retrieve_list_of_columns(get_boards, create_board, get_me):

    # Arrange
    title = 'Text Column 1'
    column_type = ColumnType.text
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': '1', 'name': 'Test Board 1'}
    get_boards.return_value = [{'id': '1', 'columns': [{'id': '1', 'title': title, 'type': column_type.name}]}]
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act 
    columns = board.get_columns()

    # Assert
    ok_(columns != None)
    eq_(len(columns), 1)
    eq_(columns[0].title, title)
    eq_(columns[0].column_type, column_type)
コード例 #14
0
def test_board_should_create_an_item_with_list_column_values(create_item, create_board, get_me):

    # Arrange
    board_id = '3'
    name = 'Item 4'
    group_id = 'group2'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    create_item.return_value = {'id': '4', 'name': name}
    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)
    status_column = cv.create_column_value(ColumnType.status, id='status', title='Status', value=json.dumps({'index': 0}), settings=en.objects.StatusSettings({'labels': {'0':'Test'}}))

    # Act 
    item = board.add_item(name, group_id=group_id, column_values=[status_column])

    # Assert
    ok_(item != None)
    eq_(item.name, name)
コード例 #15
0
def test_should_create_webhook(create_webhook, create_board, get_me):

    # Arrange
    board_id = '1'
    webhook_id = '12345'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    create_webhook.return_value = {'board_id': board_id, 'id': webhook_id}

    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act
    webhook = board.create_webhook('http://test.webhook.com/webhook/test', WebhookEventType.create_item)

    # Assert 
    ok_(webhook != None)
    eq_(webhook.board_id, board_id)
    eq_(webhook.id, webhook_id)
    ok_(webhook.is_active)
コード例 #16
0
def test_should_delete_webhook(delete_webhook, create_board, get_me):

    # Arrange
    board_id = '1'
    webhook_id = '12345'
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {'id': board_id, 'name': 'Test Board 1'}
    delete_webhook.return_value = {'board_id': board_id, 'id': webhook_id}

    client = MondayClient(USERNAME, '', '')
    board = client.create_board('Test Board 1', BoardKind.public)

    # Act
    webhook = board.delete_webhook(webhook_id)

    # Assert 
    ok_(webhook != None)
    eq_(webhook.board_id, board_id)
    eq_(webhook.id, webhook_id)
    ok_(not webhook.is_active)
コード例 #17
0
def test_should_create_a_new_board(get_me, create_board):

    # Arrange
    board_name = 'New Board 1'
    board_kind = BoardKind.private
    get_me.return_value = GET_ME_RETURN_VALUE
    create_board.return_value = {
        'id': '1',
        'name': board_name,
        'board_kind': board_kind.name
    }
    client = MondayClient(USERNAME, '', '')

    # Act
    board = client.create_board(board_name, board_kind)

    # Assert
    ok_(board != None)
    eq_(board.name, board_name)
    eq_(board.board_kind, board_kind.name)
コード例 #18
0
#!/usr/local/bin/python3
from moncli import MondayClient
from moncli import BoardKind
from moncli import ColumnType

# Instantiating a new client interface to Monday.com
client = MondayClient(user_name='*****@*****.**', api_key_v1='eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjkxNTcxMzE0LCJ1aWQiOjE3Mjk4ODA2LCJpYWQiOiIyMDIwLTExLTIxVDE0OjQzOjE5LjAwMFoiLCJwZXIiOiJtZTp3cml0ZSJ9.G7UsLWL1XKlmClx5lFMxLK_yYG8f2WslO9idr3li09Y', api_key_v2='eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjkxNTcxMzE0LCJ1aWQiOjE3Mjk4ODA2LCJpYWQiOiIyMDIwLTExLTIxVDE0OjQzOjE5LjAwMFoiLCJwZXIiOiJtZTp3cml0ZSJ9.G7UsLWL1XKlmClx5lFMxLK_yYG8f2WslO9idr3li09Y')

# Creating a new board in the Main Workspace
board_name = 'New Public Board'
board_kind = BoardKind.public
new_board = client.create_board(board_name, board_kind)

# Getting a board by it's ID
board_id = '881643972'
board_by_id = client.get_board(id=board_id)

# Getting a board by it's name (this does not work well as it is not native to Monday)
# board_name = 'Hack Tasks'
# retrieved_board = client.get_board(name=board_name)

# Archiving a board
# archived_board = client.archive_board(board_id)

# Add a new column to the board
new_column = board.add_column(title='New Text Column', column_type=ColumnType.text)

# Retrieving Columns from a board
columns = board.get_columns('id', 'title', 'type')

# Retrieving Groups from a board
コード例 #19
0
#student_workspace_id = student_workspace['id']

# 1. Setup Monday Workspace and Groups
b_name = "{} - School Board".format(student_name)
try: 
    # 1a. First check to see if the board already exists
    school_board = client.get_board_by_name(b_name)
    board_does_not_exist = False
except:
    board_does_not_exist = True
    
if board_does_not_exist:
    # 1b. Create new board
    #school_board = client.create_board(name=board_name, kind=board_kind, 'id', 'name')
    #school_board = client.create_board(board_name=b_name, board_kind=BoardKind.public, workspace_id='id', 'name')
    school_board = client.create_board(b_name, BoardKind.public)

# 2. Build a group called <UserName>'s Courses from Google Classroom API
new_group_name = "{} - Courses".format(student_name)

try: 
    # 2a. First check to see if the group already exists
    course_group = school_board.get_group(None, new_group_name)
    group_does_not_exist = False
except:
    group_does_not_exist = True

if group_does_not_exist:
    # 2b. Create new group
    course_group = school_board.add_group(new_group_name)
    #2c. Add Columns to group