# Path: tensorflow_transform/test_case.py
# def is_tf_api_version_1():
# def cross_named_parameters(*args):
#   def _cross_test_cases(parameters_list):
# def parameters(*testcases):
#   def wrapper(fn):
#     def to_arg_dict(testcase):
# def cross_parameters(*args):
# def _make_placeholder(tensor_spec):
# def _graph_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_graph(*inputs):
# def _ragged_value_as_constant(value, dtype):
# def _wrap_as_constant(value, tensor_spec):
# def _eager_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_eagerly(*inputs):  # pylint: disable=missing-docstring
# def _tf_function_function_handler(input_signature):
#   def wrapper(fn):
# def is_external_environment():
# def skip_if_external_environment(reason):
# def skip_if_not_tf2(reason):
# def cross_with_function_handlers(parameters_list):
#   def assertDataCloseOrEqual(self, a_data, b_data):
#   def _assertValuesCloseOrEqual(self, a_value, b_value, msg=None):
#   def AssertVocabularyContents(self, vocab_file_path, file_contents):
#   def WriteRenderedDotFile(self, dot_string, output_file=None):
#   def _NumpyArraysToLists(self, maybe_arrays):
#   def _SortedDicts(self, list_of_dicts):
#   def _SortedData(self, list_of_dicts_of_arrays):
# FUNCTION_HANDLERS = [
#     dict(testcase_name='graph',
#          function_handler=_graph_function_handler),
#     dict(testcase_name='eager',
#          function_handler=_eager_function_handler),
#     dict(testcase_name='tf_function',
#          function_handler=_tf_function_function_handler)
# ]
# class TransformTestCase(parameterized.TestCase, tf.test.TestCase):


import os
import shutil
import tensorflow as tf
import tensorflow_transform as tft
import sentiment_example
import local_model_server
from tensorflow_transform import test_case
          # Use made up data chosen to give high probability of negative
          # sentiment.
          ascii_classification_request = """model_spec { name: "my_model" }
  input {
    example_list {
      examples {
        features {
          feature {
            key: "review"
            value: {
              bytes_list {
                value: "errible terrible terrible terrible terrible terrible terrible."
              }
            }
          }
        }
      }
    }
  }"""
          results = local_model_server.make_classification_request(
              address, ascii_classification_request)
          self.assertEqual(len(results), 1)
          self.assertEqual(len(results[0].classes), 2)
          self.assertEqual(results[0].classes[0].label, '0')
          self.assertGreater(results[0].classes[0].score, 0.8)
          self.assertEqual(results[0].classes[1].label, '1')
          self.assertLess(results[0].classes[1].score, 0.2)


if __name__ == '__main__':

# Path: tensorflow_transform/test_case.py
# def is_tf_api_version_1():
# def cross_named_parameters(*args):
#   def _cross_test_cases(parameters_list):
# def parameters(*testcases):
#   def wrapper(fn):
#     def to_arg_dict(testcase):
# def cross_parameters(*args):
# def _make_placeholder(tensor_spec):
# def _graph_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_graph(*inputs):
# def _ragged_value_as_constant(value, dtype):
# def _wrap_as_constant(value, tensor_spec):
# def _eager_function_handler(input_signature):
#   def wrapper(fn):
#     def _run_eagerly(*inputs):  # pylint: disable=missing-docstring
# def _tf_function_function_handler(input_signature):
#   def wrapper(fn):
# def is_external_environment():
# def skip_if_external_environment(reason):
# def skip_if_not_tf2(reason):
# def cross_with_function_handlers(parameters_list):
#   def assertDataCloseOrEqual(self, a_data, b_data):
#   def _assertValuesCloseOrEqual(self, a_value, b_value, msg=None):
#   def AssertVocabularyContents(self, vocab_file_path, file_contents):
#   def WriteRenderedDotFile(self, dot_string, output_file=None):
#   def _NumpyArraysToLists(self, maybe_arrays):
#   def _SortedDicts(self, list_of_dicts):
#   def _SortedData(self, list_of_dicts_of_arrays):
# FUNCTION_HANDLERS = [
#     dict(testcase_name='graph',
#          function_handler=_graph_function_handler),
#     dict(testcase_name='eager',
#          function_handler=_eager_function_handler),
#     dict(testcase_name='tf_function',
#          function_handler=_tf_function_function_handler)
# ]
# class TransformTestCase(parameterized.TestCase, tf.test.TestCase):


# Path: examples/sentiment_example_test.py
import os
import shutil
import tensorflow as tf
import tensorflow_transform as tft
import sentiment_example
import local_model_server
from tensorflow_transform import test_case

          # Use made up data chosen to give high probability of negative
          # sentiment.
          ascii_classification_request = """model_spec { name: "my_model" }
  input {
    example_list {
      examples {
        features {
          feature {
            key: "review"
            value: {
              bytes_list {
                value: "errible terrible terrible terrible terrible terrible terrible."
              }
            }
          }
        }
      }
    }
  }"""
          results = local_model_server.make_classification_request(
              address, ascii_classification_request)
          self.assertEqual(len(results), 1)
          self.assertEqual(len(results[0].classes), 2)
          self.assertEqual(results[0].classes[0].label, '0')
          self.assertGreater(results[0].classes[0].score, 0.8)
          self.assertEqual(results[0].classes[1].label, '1')
          self.assertLess(results[0].classes[1].score, 0.2)


if __name__ == '__main__':

  tf.test.main()