text: import unittest
  from nextactions.board import Board
  from nextactions.card import Card
  from nextactions.trello import Trello
  from unittest.mock import MagicMock, patch
  
  
  class TestCard(unittest.TestCase):
  
      def testIsAutoGenerated(self):
          card1 = Card(None, self._getCardJson())
          card2_desc = "http://trello.com/c/123 " + Card.AUTO_GENERATED_TEXT
          card2 = Card(None, self._getCardJson({'desc': card2_desc}))
          self.assertFalse(card1.isAutoGenerated())
          self.assertTrue(card2.isAutoGenerated())
  
      def _getCardJson(self, override=None):
          defaults = {
              'id': "123",
              'name': "Card",
              'idBoard': "456",
              'desc': "Test",
              'url': "fake"
          }
          if override is not None:
              return {**defaults, **override}
          else:
              return defaults
  
      def testGetProjectBoardInvalid(self):
          card = Card(None, self._getCardJson())
          with self.assertRaises(ValueError):
              card.getProjectBoard()
  
      @patch('nextactions.board.Board')
      @patch('nextactions.trello.Trello')
      def testGetProjectBoard(self, trello, board):
          trello.getBoardById.return_value = board
          card_desc = "http://trello.com/c/789"
          card = Card(trello, self._getCardJson({'desc': card_desc}))
          project_board = card.getProjectBoard()
          trello.getBoardById.assert_called_once_with("789")
          self.assertEqual(project_board, board)
  
      def testNotEqual(self):
          card1 = Card(None, self._getCardJson())
          card2 = Card(None, self._getCardJson({'id': "456"}))
          self.assertFalse(card1 == card2)
  
      def testEqual(self):
          card1 = Card(None, self._getCardJson())
          card2 = Card(None, self._getCardJson())
          self.assertEqual(card1, card2)
  
      def testLinksTo(self):
          card1 = Card(None, self._getCardJson({
              'desc': "https://trello.com/c/test\n\n"
                      + Card.AUTO_GENERATED_TEXT
          }))
          card2 = Card(None, self._getCardJson({
              'url': "https://trello.com/c/test"
          }))
          self.assertFalse(card2.linksTo(card1))
          self.assertTrue(card1.linksTo(card2))
  
      @patch('nextactions.trello.Trello')
      def testArchive(self, trello):
          card = Card(trello, self._getCardJson())
          card.archive()
          trello.put.assert_called_once_with(
              'https://api.trello.com/1/cards/123/closed',
              {'value': "true"}
          )
  