Example #1
0
    def test_create_posts_expected_data(self, mock_session, user_context,
                                        mock_get_all_cases_response):
        client = DepartingEmployeeClient(mock_session, user_context)
        # Return value should have been set based on the arguments passed
        # in create, here however as we are mocking it, it doesn't matter. Can be refactored
        mock_session.post.return_value = mock_get_all_cases_response
        client.create(
            "*****@*****.**",
            None,
            "These are notes",
            2352463246,
            True,
            ["*****@*****.**"],
        )

        # Have to convert the request data to a dict because
        # older versions of Python don't have deterministic order.
        posted_data = json.loads(mock_session.post.call_args[1]["data"])
        assert (posted_data["userName"] == "*****@*****.**"
                and posted_data["tenantId"] == TENANT_ID_FROM_RESPONSE
                and posted_data["notes"] == "These are notes"
                and posted_data["departureDate"] == "2044-07-18T14:00:46.000Z"
                and posted_data["alertsEnabled"] == True
                and posted_data["cloudUsernames"]
                == ["*****@*****.**"])
Example #2
0
 def test_create_posts_to_expected_url(self, mock_session, user_context,
                                       mock_get_all_cases_response_empty):
     client = DepartingEmployeeClient(mock_session, user_context)
     mock_session.post.return_value = mock_get_all_cases_response_empty
     client.create("*****@*****.**")
     assert mock_session.post.call_args[0][
         0] == "/svc/api/v1/departingemployee/create"
Example #3
0
 def test_create_uses_given_tenant_id_over_current_id(
         self, mock_session, user_context, mock_get_all_cases_response):
     client = DepartingEmployeeClient(mock_session, user_context)
     mock_session.post.return_value = mock_get_all_cases_response
     client.create("*****@*****.**", _TENANT_ID_PARAM)
     post_call_args = json.loads(mock_session.post.call_args[1]["data"])
     assert post_call_args["tenantId"] == _TENANT_ID_PARAM