def test_is_detached_not(self, mocker): mock_query_set.count.return_value = 0 label = Label(id=37) ret = label.is_detached() assert ret is False Label.objects.filter.assert_called_with(id=37, unifiedjob_labels__isnull=True, unifiedjobtemplate_labels__isnull=True) mock_query_set.count.assert_called_with()
def test_is_detached(self, mocker): mock_query_set.exists.return_value = True label = Label(id=37) ret = label.is_detached() assert ret is True Label.objects.filter.assert_called_with( id=37, unifiedjob_labels__isnull=True, unifiedjobtemplate_labels__isnull=True, inventory_labels__isnull=True) mock_query_set.exists.assert_called_with()