# Path: test/tools/mock_descriptors.py
# def make_field(
#     name: str = "my_field",
#     number: int = 1,
#     proto_type: str = "TYPE_MESSAGE",
#     type_name: str = ".example.v1.foo",  # type_name should be set if the field is message type.
#     repeated: bool = False,
#     required: bool = False,
#     oneof: bool = False,
#     options: desc.FieldOptions = None,
#     resource_database: ResourceDatabase = None,
#     message_resource: resource_pb2.ResourceDescriptor = None,
#     proto_file_name: str = "foo",
#     locations: Sequence[desc.SourceCodeInfo.Location] = [],
#     path: Tuple[int] = (),
#     api_version: str = None,
#     map_entry=None,
#     oneof_index: int = None,
#     oneof_name: str = None,
#     proto3_optional: bool = False,
#     nested_path: Sequence[str] = [],
#     **kwargs,
# ) -> wrappers.Field:
#     T = desc.FieldDescriptorProto.Type
#     type_value = T.Value(proto_type)
#     label = 3 if repeated else 1
# 
#     field_pb = make_field_pb2(
#         name=name,
#         number=number,
#         label=label,
#         proto_type=type_value,
#         type_name=type_name,
#         oneof_index=oneof_index,
#         proto3_optional=proto3_optional,
#         options=options,
#         **kwargs,
#     )
#     # Set the Field_behavior option as required.
#     if required:
#         field_pb.options.Extensions[field_behavior_pb2.field_behavior].append(
#             field_behavior_pb2.FieldBehavior.Value("REQUIRED")
#         )
#     source_code_locations = {tuple(location.path): location for location in locations}
# 
#     return wrappers.Field(
#         field_pb=field_pb,
#         proto_file_name=proto_file_name,
#         source_code_locations=source_code_locations,
#         path=path,
#         resource_database=resource_database,
#         message_resource=message_resource,
#         api_version=api_version,
#         map_entry=map_entry,
#         oneof_name=oneof_name,
#         nested_path=nested_path,
#     )


import unittest
from test.tools.mock_descriptors import make_field
from google.protobuf import descriptor_pb2
from google.api import field_behavior_pb2
from google.api import resource_pb2
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class FieldTest(unittest.TestCase):
    def test_basic_properties(self):
        field = make_field("Foo")
        self.assertEqual(field.name, "Foo")
        self.assertEqual(field.number, 1)
        self.assertEqual(field.proto_type.value, "message")
        self.assertEqual(field.oneof, False)
        self.assertEqual(field.proto_file_name, "foo")
        self.assertEqual(field.api_version, None)
        self.assertEqual(field.map_entry, None)

    def test_api_version(self):
        field = make_field("Foo", api_version="v1")
        self.assertEqual(field.name, "Foo")
        self.assertEqual(field.api_version, "v1")

    def test_field_is_primitive(self):

# Path: test/tools/mock_descriptors.py
# def make_field(
#     name: str = "my_field",
#     number: int = 1,
#     proto_type: str = "TYPE_MESSAGE",
#     type_name: str = ".example.v1.foo",  # type_name should be set if the field is message type.
#     repeated: bool = False,
#     required: bool = False,
#     oneof: bool = False,
#     options: desc.FieldOptions = None,
#     resource_database: ResourceDatabase = None,
#     message_resource: resource_pb2.ResourceDescriptor = None,
#     proto_file_name: str = "foo",
#     locations: Sequence[desc.SourceCodeInfo.Location] = [],
#     path: Tuple[int] = (),
#     api_version: str = None,
#     map_entry=None,
#     oneof_index: int = None,
#     oneof_name: str = None,
#     proto3_optional: bool = False,
#     nested_path: Sequence[str] = [],
#     **kwargs,
# ) -> wrappers.Field:
#     T = desc.FieldDescriptorProto.Type
#     type_value = T.Value(proto_type)
#     label = 3 if repeated else 1
# 
#     field_pb = make_field_pb2(
#         name=name,
#         number=number,
#         label=label,
#         proto_type=type_value,
#         type_name=type_name,
#         oneof_index=oneof_index,
#         proto3_optional=proto3_optional,
#         options=options,
#         **kwargs,
#     )
#     # Set the Field_behavior option as required.
#     if required:
#         field_pb.options.Extensions[field_behavior_pb2.field_behavior].append(
#             field_behavior_pb2.FieldBehavior.Value("REQUIRED")
#         )
#     source_code_locations = {tuple(location.path): location for location in locations}
# 
#     return wrappers.Field(
#         field_pb=field_pb,
#         proto_file_name=proto_file_name,
#         source_code_locations=source_code_locations,
#         path=path,
#         resource_database=resource_database,
#         message_resource=message_resource,
#         api_version=api_version,
#         map_entry=map_entry,
#         oneof_name=oneof_name,
#         nested_path=nested_path,
#     )


# Path: test/comparator/wrappers/test_field.py
import unittest
from test.tools.mock_descriptors import make_field
from google.protobuf import descriptor_pb2
from google.api import field_behavior_pb2
from google.api import resource_pb2

# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



class FieldTest(unittest.TestCase):
    def test_basic_properties(self):
        field = make_field("Foo")
        self.assertEqual(field.name, "Foo")
        self.assertEqual(field.number, 1)
        self.assertEqual(field.proto_type.value, "message")
        self.assertEqual(field.oneof, False)
        self.assertEqual(field.proto_file_name, "foo")
        self.assertEqual(field.api_version, None)
        self.assertEqual(field.map_entry, None)

    def test_api_version(self):
        field = make_field("Foo", api_version="v1")
        self.assertEqual(field.name, "Foo")
        self.assertEqual(field.api_version, "v1")

    def test_field_is_primitive(self):

        primitive_field = make_field(proto_type="TYPE_INT32")