"""Test for model identity.""" from unittest.mock import patch from notifications.models import identity def test_get_identity_for_label_profile(): """Test get_identity_for_label_profile.""" label_profile_id = 1234 with patch('notifications.models.identity.get_session') as mock_fn: session_mock = mock_fn.return_value identity.get_identity_for_label_profile(label_profile_id) assert session_mock.run.call_count == 1 assert session_mock.run.call_args[0] == ( 'MATCH (i:Identity)-[:HAS_PROFILE]->(p:Profile {profileType: "LabelProfile"}) WHERE p.profileId = $profileId RETURN i as identity', # noqa: E501 ) assert session_mock.run.call_args[1] == {'profileId': label_profile_id} def test_get_resource_by_id_type(): """Test get_resource_by_id_type.""" entity_type = 'Vendor' entity_id = 7123 with patch('notifications.models.identity.get_session') as mock_fn: session_mock = mock_fn.return_value identity.get_resource_by_id_type(entity_type, entity_id) assert session_mock.run.call_count == 1 assert session_mock.run.call_args[0] == ( 'MATCH (r:Vendor) WHERE r.id = $id RETURN r as resource LIMIT 1', ) assert session_mock.run.call_args[1] == {'id': entity_id}