Exemplo n.º 1
0
    def test_nr_of_inactive_cards_when_http_error(self, mock_url_open):
        """ Test that when there is an HTTP error during retrieval, it returns an empty list as overdue cards. """
        mock_url_open.side_effect = urllib.error.HTTPError(
            None, None, None, None, None)
        trello_board = TrelloBoard('appkeyX', 'tokenX')

        self.assertEqual(-1, trello_board.nr_of_inactive_cards('board_id'))
Exemplo n.º 2
0
    def test_nr_of_inactive_cards(self, mock_url_read):
        """ Test the inactive card for exactly 14 days. """
        from datetime import datetime
        with patch(__name__ + '.datetime.datetime') as mock_date:
            mock_date.now.return_value = datetime(2018, 3, 21)
            mock_date.side_effect = lambda *args, **kw: datetime(*args, **kw)

            mock_url_read.return_value = '{"id": "x", "dateLastActivity":"2018-03-05T11:00:00.000Z", ' \
                                         '"url": "", "lists": [], "cards": [{"id": "card_id", "idList": ' \
                                         '"xx", "name": "Test card!", "shortUrl": "http://shortUrl", ' \
                                         '"dateLastActivity": "2018-03-06T11:00:00.000Z", "due": null}]}'
            trello_board = TrelloBoard('appkeyX', 'tokenX')

            result = trello_board.nr_of_inactive_cards('board_id')

        self.assertEqual(1, result)
Exemplo n.º 3
0
    def test_nr_of_inactive_cards(self, mock_url_read):
        """ Test the inactive card for exactly 14 days. """
        from datetime import datetime
        with patch(__name__ + '.datetime.datetime') as mock_date:
            mock_date.now.return_value = datetime(2018, 3, 21)
            mock_date.side_effect = lambda *args, **kw: datetime(*args, **kw)

            mock_url_read.return_value = '{"id": "x", "dateLastActivity":"2018-03-05T11:00:00.000Z", ' \
                                         '"url": "", "lists": [], "cards": [{"id": "card_id", "idList": ' \
                                         '"xx", "name": "Test card!", "shortUrl": "http://shortUrl", ' \
                                         '"dateLastActivity": "2018-03-06T11:00:00.000Z", "due": null}]}'
            trello_board = TrelloBoard('appkeyX', 'tokenX')

            result = trello_board.nr_of_inactive_cards('board_id')

        self.assertEqual(1, result)
Exemplo n.º 4
0
    def test_nr_of_inactive_cards_when_http_error(self, mock_url_open):
        """ Test that when there is an HTTP error during retrieval, it returns an empty list as overdue cards. """
        mock_url_open.side_effect = urllib.error.HTTPError(None, None, None, None, None)
        trello_board = TrelloBoard('appkeyX', 'tokenX')

        self.assertEqual(-1, trello_board.nr_of_inactive_cards('board_id'))