<commit_before>import pytest

from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.tasks.salesforce.tests.util import create_task
from cumulusci.tasks.metadata_etl import AddPicklistEntries
from cumulusci.utils.xml import metadata_tree

OBJECT_XML = b"""<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>Time_Zone__c</fullName>
        <type>Picklist</type>
        <valueSet>
            <valueSetDefinition>
                <sorted>false</sorted>
                <value>
                    <fullName>Pacific/Kiritimati</fullName>
                    <default>false</default>
                </value>
                <value>
                    <fullName>Pacific/Chatham</fullName>
                    <default>true</default>
                </value>
            </valueSetDefinition>
        </valueSet>
    </fields>
    <fields>
        <fullName>Type__c</fullName>
        <type>Picklist</type>
        <valueSet>
            <valueSetDefinition>
                <sorted>true</sorted>
                <value>
                    <fullName>Fundraising</fullName>
                    <default>false</default>
                </value>
                <value>
                    <fullName>Outreach</fullName>
                    <default>true</default>
                </value>
            </valueSetDefinition>
        </valueSet>
    </fields>
    <recordTypes>
        <fullName>Default_RT</fullName>
        <active>true</active>
        <picklistValues>
            <picklist>Type__c</picklist>
            <values>
                <fullName>Fundraising</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Outreach</fullName>
                <default>true</default>
            </values>
        </picklistValues>
        <picklistValues>
            <picklist>Time_Zone__c</picklist>
            <values>
                <fullName>Pacific%2FKiritimati</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Pacific%2FChatham</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>
    <recordTypes>
        <fullName>Second_RT</fullName>
        <active>true</active>
        <picklistValues>
            <picklist>Type__c</picklist>
            <values>
                <fullName>Fundraising</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Outreach</fullName>
                <default>true</default>
            </values>
        </picklistValues>
        <picklistValues>
            <picklist>Time_Zone__c</picklist>
            <values>
                <fullName>Pacific%2FKiritimati</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Pacific%2FChatham</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>
</CustomObject>
"""


class TestAddPicklistValues:
    def test_sets_sorted(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the first sObject has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        vsd = result.find("fields", fullName="Time_Zone__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "true"

    def test_adds_values(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the first sObject has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        values = result.find(
            "fields", fullName="Time_Zone__c"
        ).valueSet.valueSetDefinition.value

        test_elem = next(v for v in values if v.fullName.text == "Test")
        assert test_elem is not None
        assert test_elem.label.text == "Test"
        assert test_elem.default.text == "false"

        test_elem = next(v for v in values if v.fullName.text == "Foo")
        assert test_elem is not None
        assert test_elem.label.text == "Bar"
        assert test_elem.default.text == "true"

        test_elem = next(v for v in values if v.fullName.text == "Pacific/Chatham")
        assert test_elem.default.text == "false"

        # Show that the other picklist is unaffected
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value
        assert "Test" not in (v.fullName.text for v in values)

    def test_does_not_add_duplicate_values(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [{"fullName": "Outreach"}],
                "sorted": True,
            },
        )

        # Validate that the duplicate entry is not added
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value

        test_elem = list(v for v in values if v.fullName.text == "Outreach")
        assert len(test_elem) == 1

    def test_adds_values__unsorted(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
            },
        )

        # Validate that the sorted attribute is not changed.
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        vsd = result.find("fields", fullName="Time_Zone__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "false"

        result = task._transform_entity(tree, "MyObject2")
        vsd = result.find("fields", fullName="Type__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "true"

    def test_adds_values_second_object(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the second object has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value

        test_elem = next(v for v in values if v.fullName.text == "Test")
        assert test_elem is not None
        assert test_elem.label.text == "Test"
        assert test_elem.default.text == "false"

        test_elem = next(v for v in values if v.fullName.text == "Foo")
        assert test_elem is not None
        assert test_elem.label.text == "Bar"
        assert test_elem.default.text == "true"

        test_elem = next(v for v in values if v.fullName.text == "Outreach")
        assert test_elem.default.text == "false"

        # Show that the other picklist is unaffected
        values = result.find(
            "fields", fullName="Time_Zone__c"
        ).valueSet.valueSetDefinition.value
        assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["*"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        for rt_name in ["Default_RT", "Second_RT"]:
            # Make sure we added the picklist values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Type__c")
                .values
            )
            assert "Test" in (v.fullName.text for v in values)
            assert "Foo" in (v.fullName.text for v in values)

            # Check that we set the default
            foo_value = next(v for v in values if v.fullName.text == "Foo")
            assert foo_value.default.text == "true"

            outreach_value = next(v for v in values if v.fullName.text == "Outreach")
            assert outreach_value.default.text == "false"

            # And that we did not add the other picklist's values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Time_Zone__c")
                .values
            )
            assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries__single(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["Default_RT"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        values = (
            result.find("recordTypes", fullName="Default_RT")
            .find("picklistValues", picklist="Type__c")
            .values
        )
        assert "Test" in (v.fullName.text for v in values)
        assert "Foo" in (v.fullName.text for v in values)

        values = (
            result.find("recordTypes", fullName="Second_RT")
            .find("picklistValues", picklist="Type__c")
            .values
        )
        assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries__multiple(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["Default_RT", "Second_RT"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        for rt_name in ["Default_RT", "Second_RT"]:
            # Make sure we added the picklist values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Type__c")
                .values
            )
            assert "Test" in (v.fullName.text for v in values)
            assert "Foo" in (v.fullName.text for v in values)

    def test_init_options__bad_api_version(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "35.0",
                    "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__bad_picklist_name(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["MyObjectTime_Zone__c"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__standard_picklist_name(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.StageName"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__missing_fullname(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.StageName"],
                    "entries": [{"label": "Test"}],
                },
            )

    def test_init_options__multiple_defaults(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.StageName"],
                    "entries": [
                        {"fullName": "Test", "default": True},
                        {"fullName": "Bar", "default": True},
                    ],
                },
            )<commit_msg>Cover missed code paths<commit_after>import pytest

from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.tasks.salesforce.tests.util import create_task
from cumulusci.tasks.metadata_etl import AddPicklistEntries
from cumulusci.utils.xml import metadata_tree

OBJECT_XML = b"""<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>Time_Zone__c</fullName>
        <type>Picklist</type>
        <valueSet>
            <valueSetDefinition>
                <sorted>false</sorted>
                <value>
                    <fullName>Pacific/Kiritimati</fullName>
                    <default>false</default>
                </value>
                <value>
                    <fullName>Pacific/Chatham</fullName>
                    <default>true</default>
                </value>
            </valueSetDefinition>
        </valueSet>
    </fields>
    <fields>
        <fullName>Type__c</fullName>
        <type>Picklist</type>
        <valueSet>
            <valueSetDefinition>
                <sorted>true</sorted>
                <value>
                    <fullName>Fundraising</fullName>
                    <default>false</default>
                </value>
                <value>
                    <fullName>Outreach</fullName>
                    <default>true</default>
                </value>
            </valueSetDefinition>
        </valueSet>
    </fields>
    <recordTypes>
        <fullName>Default_RT</fullName>
        <active>true</active>
        <picklistValues>
            <picklist>Type__c</picklist>
            <values>
                <fullName>Fundraising</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Outreach</fullName>
                <default>true</default>
            </values>
        </picklistValues>
        <picklistValues>
            <picklist>Time_Zone__c</picklist>
            <values>
                <fullName>Pacific%2FKiritimati</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Pacific%2FChatham</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>
    <recordTypes>
        <fullName>Second_RT</fullName>
        <active>true</active>
        <picklistValues>
            <picklist>Type__c</picklist>
            <values>
                <fullName>Fundraising</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Outreach</fullName>
                <default>true</default>
            </values>
        </picklistValues>
        <picklistValues>
            <picklist>Time_Zone__c</picklist>
            <values>
                <fullName>Pacific%2FKiritimati</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Pacific%2FChatham</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>
</CustomObject>
"""


class TestAddPicklistValues:
    def test_sets_sorted(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the first sObject has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        vsd = result.find("fields", fullName="Time_Zone__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "true"

    def test_adds_values(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the first sObject has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        values = result.find(
            "fields", fullName="Time_Zone__c"
        ).valueSet.valueSetDefinition.value

        test_elem = next(v for v in values if v.fullName.text == "Test")
        assert test_elem is not None
        assert test_elem.label.text == "Test"
        assert test_elem.default.text == "false"

        test_elem = next(v for v in values if v.fullName.text == "Foo")
        assert test_elem is not None
        assert test_elem.label.text == "Bar"
        assert test_elem.default.text == "true"

        test_elem = next(v for v in values if v.fullName.text == "Pacific/Chatham")
        assert test_elem.default.text == "false"

        # Show that the other picklist is unaffected
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value
        assert "Test" not in (v.fullName.text for v in values)

    def test_does_not_add_duplicate_values(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [{"fullName": "Outreach"}],
                "sorted": True,
            },
        )

        # Validate that the duplicate entry is not added
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value

        test_elem = list(v for v in values if v.fullName.text == "Outreach")
        assert len(test_elem) == 1

    def test_adds_values__unsorted(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
            },
        )

        # Validate that the sorted attribute is not changed.
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject")
        vsd = result.find("fields", fullName="Time_Zone__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "false"

        result = task._transform_entity(tree, "MyObject2")
        vsd = result.find("fields", fullName="Type__c").valueSet.valueSetDefinition
        assert vsd.sorted.text == "true"

    def test_adds_values_second_object(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "sorted": True,
            },
        )

        # Validate that the second object has one picklist changed
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")
        values = result.find(
            "fields", fullName="Type__c"
        ).valueSet.valueSetDefinition.value

        test_elem = next(v for v in values if v.fullName.text == "Test")
        assert test_elem is not None
        assert test_elem.label.text == "Test"
        assert test_elem.default.text == "false"

        test_elem = next(v for v in values if v.fullName.text == "Foo")
        assert test_elem is not None
        assert test_elem.label.text == "Bar"
        assert test_elem.default.text == "true"

        test_elem = next(v for v in values if v.fullName.text == "Outreach")
        assert test_elem.default.text == "false"

        # Show that the other picklist is unaffected
        values = result.find(
            "fields", fullName="Time_Zone__c"
        ).valueSet.valueSetDefinition.value
        assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["*"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        for rt_name in ["Default_RT", "Second_RT"]:
            # Make sure we added the picklist values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Type__c")
                .values
            )
            assert "Test" in (v.fullName.text for v in values)
            assert "Foo" in (v.fullName.text for v in values)

            # Check that we set the default
            foo_value = next(v for v in values if v.fullName.text == "Foo")
            assert foo_value.default.text == "true"

            outreach_value = next(v for v in values if v.fullName.text == "Outreach")
            assert outreach_value.default.text == "false"

            # And that we did not add the other picklist's values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Time_Zone__c")
                .values
            )
            assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries__single(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["Default_RT"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        values = (
            result.find("recordTypes", fullName="Default_RT")
            .find("picklistValues", picklist="Type__c")
            .values
        )
        assert "Test" in (v.fullName.text for v in values)
        assert "Foo" in (v.fullName.text for v in values)

        values = (
            result.find("recordTypes", fullName="Second_RT")
            .find("picklistValues", picklist="Type__c")
            .values
        )
        assert "Test" not in (v.fullName.text for v in values)

    def test_adds_record_type_entries__multiple(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                "entries": [
                    {"fullName": "Test"},
                    {"fullName": "Foo", "label": "Bar", "default": True},
                ],
                "record_types": ["Default_RT", "Second_RT"],
            },
        )

        # Validate that the entries are added to the Record Type
        tree = metadata_tree.fromstring(OBJECT_XML)
        result = task._transform_entity(tree, "MyObject2")

        for rt_name in ["Default_RT", "Second_RT"]:
            # Make sure we added the picklist values
            values = (
                result.find("recordTypes", fullName=rt_name)
                .find("picklistValues", picklist="Type__c")
                .values
            )
            assert "Test" in (v.fullName.text for v in values)
            assert "Foo" in (v.fullName.text for v in values)

    def test_init_options__old_api_version(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "35.0",
                    "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__bad_api_version(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "35q.0",
                    "picklists": ["MyObject.Time_Zone__c", "MyObject2.Type__c"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__bad_picklist_name(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["MyObjectTime_Zone__c"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__standard_picklist_name(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.StageName"],
                    "entries": [{"fullName": "Test"}],
                },
            )

    def test_init_options__missing_fullname(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.Type__c"],
                    "entries": [{"label": "Test"}],
                },
            )

    def test_init_options__multiple_defaults(self):
        with pytest.raises(TaskOptionsError):
            create_task(
                AddPicklistEntries,
                {
                    "api_version": "47.0",
                    "picklists": ["Opportunity.Type__c"],
                    "entries": [
                        {"fullName": "Test", "default": True},
                        {"fullName": "Bar", "default": True},
                    ],
                },
            )

    def test_raises_for_missing_picklist(self):
        task = create_task(
            AddPicklistEntries,
            {
                "api_version": "47.0",
                "picklists": ["Opportunity.Type2__c"],
                "entries": [
                    {"fullName": "Test", "default": True},
                    {"fullName": "Bar", "default": True},
                ],
            },
        )
        tree = metadata_tree.fromstring(OBJECT_XML)
        with pytest.raises(TaskOptionsError):
            task._transform_entity(tree, "MyObject")
{'fraction_non_alphanumeric': 0.1156744911849663, 'fraction_numerical': 0.004781035226933165, 'mean_word_length': 1.6193582050613098, 'pattern_counts': {'":': 177, '<': 257, '<?xml version=': 2, '>': 257, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4887290', 'n_tokens_mistral': 8605, 'n_tokens_neox': 8113, 'n_words': 1665}