<commit_before>import json
import logging

from tests.framework.constants import GO_EP1_ID, GO_EP2_ID
from tests.framework.cli_testcase import CliTestCase

log = logging.getLogger(__name__)


class JMESPathTests(CliTestCase):
    """
    Tests bookmark commands
    """
    def test_jmespath_noop(self):
        """
        Runs some simple fetch operations and confirms that `--jmespath '@'`
        doesn't change the output (but also that it overrides --format TEXT)
        """
        output = self.run_line(
            "globus endpoint show {} -Fjson".format(GO_EP1_ID))
        jmespathoutput = self.run_line(
            "globus endpoint show {} -Ftext --jmespath '@'".format(GO_EP1_ID))
        self.assertEquals(output, jmespathoutput)

    def test_jmespath_extract_from_list(self):
        """
        Uses jmespath to extract a value from a list result using a filter.
        Confirms that the result is identical to a direct fetch of that
        resource.
        """
        self.maxDiff = None
        # list tutorial endpoints with a search, but extract go#ep2<commit_msg>Work around concurrent test runs<commit_after>import json
import logging

from tests.framework.constants import GO_EP1_ID, GO_EP2_ID
from tests.framework.cli_testcase import CliTestCase

log = logging.getLogger(__name__)


class JMESPathTests(CliTestCase):
    """
    Tests bookmark commands
    """
    def test_jmespath_noop(self):
        """
        Runs some simple fetch operations and confirms that `--jmespath '@'`
        doesn't change the output (but also that it overrides --format TEXT)
        """
        output = self.run_line(
            "globus endpoint show {} -Fjson".format(GO_EP1_ID))
        jmespathoutput = self.run_line(
            "globus endpoint show {} -Ftext --jmespath '@'".format(GO_EP1_ID))

        # Drop fields that can be affected by concurrent test runs
        output_json_dict = json.loads(output)
        output_jmespath_dict = json.loads(jmespathoutput)
        for obj in (output_json_dict, output_jmespath_dict):
            obj.pop('in_use')
            obj.pop('expire_time')
        output_fixed = json.dumps(output_json_dict)
        jmespathoutput_fixed = json.dumps(output_jmespath_dict)

        self.assertEquals(output_fixed, jmespathoutput_fixed)

    def test_jmespath_extract_from_list(self):
        """
        Uses jmespath to extract a value from a list result using a filter.
        Confirms that the result is identical to a direct fetch of that
        resource.
        """
        self.maxDiff = None
        # list tutorial endpoints with a search, but extract go#ep2
{'fraction_non_alphanumeric': 0.08098859315589353, 'fraction_numerical': 0.0038022813688212928, 'mean_word_length': 2.763948497854077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2354731', 'n_tokens_mistral': 775, 'n_tokens_neox': 754, 'n_words': 222}