Example #1
0
 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)
Example #3
0
 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)
Example #5
0
 def user(self):
     return User()
Example #6
0
 def created_by(self):
     user_id = self._content.get('created_by')
     return User(self.api.user_by_id(user_id))
Example #7
0
 def assigned_to(self):
     return User(self.api.user_with_id(self._content.get('assignedto_id')))
Example #8
0
 def created_by(self):
     return User(self.api.user_with_id(self._content.get('created_by')))
Example #9
0
 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()