Пример #1
0
 def setUp(self):
     self.storage_mock = Mock()
     options = Config({'host': 'xxx', 'api_key': 'yyy'})
     self.adapter = RedmineAdapter(redmine_options, self.storage_mock)
     self.issue = Card(**{
         'id': 'a84d79f572fbe7512b999c6b3cd7667cbe3138ff',
         'name': 'Destroy humanity',
         'desc': 'Humanity in our enemy',
         'due': datetime.date(1990, 1, 1),
         'idList': '4fe889e4c23b476f4a189ca6',
         'idMembers': [None],
     })
Пример #2
0
class CardToIssueTest(TestCase):
    def setUp(self):
        self.storage_mock = Mock()
        options = Config({'host': 'xxx', 'api_key': 'yyy'})
        self.adapter = RedmineAdapter(redmine_options, self.storage_mock)
        self.issue = Card(**{
            'id': 'a84d79f572fbe7512b999c6b3cd7667cbe3138ff',
            'name': 'Destroy humanity',
            'desc': 'Humanity in our enemy',
            'due': datetime.date(1990, 1, 1),
            'idList': '4fe889e4c23b476f4a189ca6',
            'idMembers': [None],
        })

    @property
    def redmine_issue(self):
        return self.adapter.convert_to_local_issue(self.issue)

    def test_new_issue_id(self):
        self.storage_mock.get_opposite_item_id.return_value = '555'
        self.assertEqual(self.redmine_issue.id, '555')

    def test_issue_assigned_to(self):
        self.storage_mock.get_user_or_member_id.return_value = 42
        self.assertEqual(self.redmine_issue.assigned_to_id, 42)

    def test_issue_subject(self):
        self.assertEqual(self.redmine_issue.subject, 'Destroy humanity')

    def test_issue_description(self):
        self.assertEqual(self.redmine_issue.description.strip(), 'Humanity in our enemy')

    def test_status(self):
        self.storage_mock.get_list_or_status_id.return_value = '123'
        self.assertEqual(self.redmine_issue.status_id, '123')

    @patch.object(redmine_options, 'project_id', 7)
    def test_project_id(self):
        self.assertEqual(self.redmine_issue.project_id, 7)

    def test_due_date(self):
        self.assertEqual(self.redmine_issue.due_date, datetime.date(1990, 1, 1))

    def test_client(self):
        self.assertEqual(self.redmine_issue.client.service_name, 'redmine')