-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_trellostats.py
51 lines (37 loc) · 1.72 KB
/
test_trellostats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pytest
from mock import Mock, MagicMock, patch
from trellostats import TrelloStats
import settings
@pytest.fixture
def ts_obj():
mock_context = dict(app_key=Mock(), app_token=Mock(), board_id=Mock())
return TrelloStats(mock_context)
@patch('trellostats.TrelloStats.get_lists')
def test_get_list_id_from_name_works(mock_get_lists, ts_obj):
mock_get_lists.return_value = [{'id': 'eh23jnd2', 'name': 'Thang'}]
list_id = ts_obj.get_list_id_from_name("Thang")
assert list_id == 'eh23jnd2'
@patch('trellostats.TrelloStats.get_lists')
def test_get_list_id_from_name_is_none_with_nonexistent_name(mock_get_lists,
ts_obj):
mock_get_lists.return_value = [{'id': 'eh23jnd2', 'name': 'Thang'}]
list_id = ts_obj.get_list_id_from_name("NotThang")
assert not list_id
@patch('trellostats.requests.get')
def test_get_lists(mock_get, ts_obj):
ts_obj.get_lists()
mock_get.assert_called_with(settings.BOARD_URL.format(ts_obj.board_id,
ts_obj.app_key,
ts_obj.app_token))
@patch('trellostats.requests.get')
def test_get_list_data(mock_get, ts_obj):
ts_obj.get_list_data('listylist')
mock_get.assert_called_with(settings.LIST_URL.format('listylist',
ts_obj.app_key,
ts_obj.app_token))
@patch('trellostats.grequests')
def test_get_history_for_cards(mock_g, ts_obj):
ts_obj._get_history_for_cards(MagicMock(spec=dict))
assert mock_g.map.called
def test_repr(ts_obj):
assert repr(ts_obj).startswith('<TrelloStats')