def test_updates_empty(self): bot = bot_factory() bot.create_issue = Mock() bot.req_bundle.get_updates = Mock(side_effect=IndexError) bot.apply_updates(initial=True, scheduled=False) bot.create_issue.assert_called_once_with( title=InitialUpdate.get_title(), body=InitialUpdate.get_empty_update_body())
def test_updates_empty(self): bot = bot_factory() bot.create_issue = Mock() bot.req_bundle.get_updates = Mock(side_effect=IndexError) bot.apply_updates(initial=True, scheduled=False) bot.create_issue.assert_called_once_with( title=InitialUpdate.get_title(), body=InitialUpdate.get_empty_update_body() )
def test_apply_update_initial_empty(self): bot = bot_factory() bot.req_bundle.get_updates = Mock() bot.req_bundle.get_updates.return_value = [("", "", "", [])] bot.provider.create_issue.return_value = None bot.apply_updates(initial=True, scheduled=False) create_issue_args_list = bot.provider.create_issue.call_args_list self.assertEqual(len(create_issue_args_list), 1) self.assertEqual(create_issue_args_list[0][1]["body"], InitialUpdate.get_empty_update_body()) self.assertEqual(create_issue_args_list[0][1]["title"], InitialUpdate.get_title())
def test_apply_update_initial_empty(self): bot = bot_factory() bot.req_bundle.get_updates = Mock() bot.req_bundle.get_updates.return_value = [] bot.provider.create_issue.return_value = None bot.apply_updates("branch", initial=True, pin_unpinned=False) create_issue_args_list = bot.provider.create_issue.call_args_list self.assertEqual(len(create_issue_args_list), 1) self.assertEqual( create_issue_args_list[0][1]["body"], InitialUpdate.get_empty_update_body() ) self.assertEqual( create_issue_args_list[0][1]["title"], InitialUpdate.get_title() )
def test_apply_update_initial_pr_still_open(self): initial_pr = pullrequest_factory( title=InitialUpdate.get_title(), state="open", ) bot = bot_factory(prs=[initial_pr]) the_requirement = Mock() update = RequirementUpdate( requirement_file="foo", requirement=the_requirement, commit_message="foo" ) bot.req_bundle.get_updates = Mock() bot.req_bundle.get_updates.return_value = [("The PR", "", "", [update])] bot.apply_updates(initial=True, scheduled=False) self.assertEqual(bot.provider.create_pull_request.called, False)
def test_get_updates(self): update = InitialUpdate([], config=self.config) req_file = Mock() req = Mock() req.key = "django" req.is_pinned = False req.latest_version_within_specs = "1.10" update.add(req, req_file) self.assertEqual("django-pin" in update, True) self.assertEqual(len(update["django-pin"]), 1) update.add(req, req_file) self.assertEqual(len(update["django-pin"]), 2) updates = [u for u in update.get_updates()] self.assertEqual(len(updates), 1)
def test_get_updates(self): update = InitialUpdate([], pin_unpinned=True) req_file = Mock() req = Mock() req.key = "django" req.is_pinned = False req.latest_version_within_specs = "1.10" update.add(req, req_file) self.assertEqual("django-pin" in update, True) self.assertEqual(len(update["django-pin"]), 1) update.add(req, req_file) self.assertEqual(len(update["django-pin"]), 2) updates = [u for u in update.get_updates()] self.assertEqual(len(updates), 1)
def test_get_updates_empty(self): update = InitialUpdate([], self.config) self.assertEqual(len([u for u in update.get_updates()]), 0)
def test_body(self): self.assertTrue("updated so far." in InitialUpdate.get_body([]))
def test_body(self): self.assertEqual("", InitialUpdate.get_body([]))
def test_get_updates_empty(self): update = InitialUpdate([]) self.assertEqual(len([u for u in update.get_updates()]), 0)