def test_set_assigned_to_invalid_user(self, mock_get): mock_response = mock.Mock() mock_response.json.return_value = copy.deepcopy(self.mock_user_data) mock_response.status_code = 200 mock_get.return_value = mock_response user = User() user._content['id'] = 5 with self.assertRaises(TestRailError) as e: self.result.assigned_to = user self.assertEqual(str(e.exception), "User with ID '%s' is not valid" % user.id)
def setUp(self): self.mock_user_data = { "email": "*****@*****.**", "id": 1, "is_active": True, "name": "Han Solo"} self.user = User(self.mock_user_data)
def test_set_assigned_to(self, mock_get): mock_response = mock.Mock() mock_response.json.return_value = copy.deepcopy(self.mock_user_data) mock_response.status_code = 200 mock_get.return_value = mock_response user = User(self.mock_user_data[1]) self.assertEqual(self.result.assigned_to.id, 1) self.result.assigned_to = user self.assertEqual(self.result._content['assignedto_id'], 2) self.assertEqual(self.result.assigned_to.id, 2)
def test_plancontainer_created_by(self, mock_get): API.flush_cache() mock_response = mock.Mock() mock_response.json.side_effect = [ self.mock_plans_data, self.mock_users ] mock_response.status_code = 200 mock_get.return_value = mock_response user = User({'id': 3}) created_by = self.client.plans().created_by(user) self.assertTrue([lambda x: isinstance(x, Plan) for x in created_by]) self.assertEqual(len(created_by), 2) self.assertEqual(created_by[0].id, 33) self.assertEqual(created_by[1].id, 44)
def user(self): return User()
def created_by(self): user_id = self._content.get('created_by') return User(self.api.user_by_id(user_id))
def assigned_to(self): return User(self.api.user_with_id(self._content.get('assignedto_id')))
def created_by(self): return User(self.api.user_with_id(self._content.get('created_by')))
def assigned_to(self): user_id = self._content.get('assignedto_id') return User(self.api.user_with_id(user_id)) if user_id else User()