def milestone(self): milestone_id = self._content.get('milestone_id') if milestone_id is None: return Milestone() return Milestone( self.api.milestone_with_id(milestone_id, self._content.get('project_id')))
def test_set_milestone(self, mock_get): mock_response = mock.Mock() mock_response.json.return_value = copy.deepcopy(self.mock_project_data) mock_response.status_code = 200 mock_get.return_value = mock_response milestone = Milestone(self.mock_mstone_data[1]) self.plan.milestone = milestone self.assertEqual(self.plan._content['milestone_id'], 7)
def test_set_milestone(self, mock_get, refresh_mock): refresh_mock.return_value = True mock_response = mock.Mock() mock_response.json.return_value = copy.deepcopy(self.mock_mstone_data) mock_response.status_code = 200 mock_get.return_value = mock_response mstone = Milestone(self.mock_mstone_data[0]) self.run.milestone = mstone self.assertEqual(self.run.milestone.id, 9)
def test_plancontainer_for_milestone(self, mock_get): mock_response = mock.Mock() mock_response.json.side_effect = [ filter(lambda x: x['milestone_id'] == 1, self.mock_plans_data), self.mock_milestone_data ] mock_response.status_code = 200 mock_get.return_value = mock_response milestone = Milestone(self.mock_milestone_data[0]) plans = self.client.plans(milestone) self.assertTrue(isinstance(plans, PlanContainer)) self.assertTrue([isinstance(p, Plan) for p in plans]) self.assertTrue([p._content['milestone_id'] == 1 for p in plans])
def setUp(self): self.mock_milestone_data = { "completed_on": 1389968184, "description": "foo", "due_on": 1391968184, "id": 1, "is_completed": True, "name": "Release 1.5", "project_id": 1, "url": "http://<server>/index.php?/milestones/view/1" } self.mock_project_data = [ { "announcement": "..", "completed_on": 1453504099, "id": 1, "is_completed": True, "name": "Project1", "show_announcement": True, "url": "http://<server>/index.php?/projects/overview/1", "suite_mode": 3 }, { "announcement": "..", "completed_on": 1453504099, "id": 2, "is_completed": True, "name": "Project2", "show_announcement": True, "url": "http://<server>/index.php?/projects/overview/1", "suite_mode": 3 } ] self.milestone = Milestone(self.mock_milestone_data)
def _update_milestone(self, obj): return Milestone(self.api.update_milestone(obj.raw_data()))
def _add_milestone(self, obj): obj.project = obj.project or self.project(self._project_id) return Milestone(self.api.add_milestone(obj.raw_data()))
def milestone(self): return Milestone()
def milestone(self): m = self.api.milestone_with_id(self._content.get('milestone_id')) return Milestone(m) if m else Milestone()
def test_get_due_on_none(self): milestone = Milestone({}) self.assertEqual(milestone.due_on, None)
def test_get_completed_on_not_completed(self): milestone = Milestone({}) self.assertEqual(milestone.completed_on, None)