# Path: vizier/service/resources.py
# def _assert_not_empty(instance: Any, attribute: Any,
#                       value: Optional[Union[str, int]]):
#   def from_name(cls, resource_name: str):
#   def owner_id(self):
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def owner_resource(self) -> OwnerResource:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def make_early_stopping_operation(self, operation_id: str = ''):
#   def study_resource(self) -> StudyResource:
#   def name(self) -> str:
#   def operation_id(self) -> str:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def trial(self) -> TrialResource:
#   def operation_id(self) -> str:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
# class OwnerResource:
# class StudyResource:
# class TrialResource:
# class EarlyStoppingOperationResource:
# class SuggestionOperationResource:
# 
# Path: vizier/service/test_util.py
# def generate_study(owner_id: str = 'my_username',
#                    study_id: str = '1234',
#                    display_name: str = 'cifar10',
#                    **study_kwargs) -> study_pb2.Study:
# def generate_trials(trial_id_list: Sequence[int],
#                     owner_id: str = 'my_username',
#                     study_id: str = '1234',
#                     **trial_kwargs) -> List[study_pb2.Trial]:
# def generate_all_states_trials(start_trial_index: int,
#                                owner_id: str = 'my_username',
#                                study_id: str = '1234',
#                                **trial_kwargs) -> List[study_pb2.Trial]:
# def generate_suggestion_operations(
#     operation_numbers: Sequence[int],
#     owner_id: str = 'my_username',
#     client_id: str = 'client0',
#     **operation_kwargs) -> List[operations_pb2.Operation]:
# def generate_early_stopping_operations(
#     trial_id_list: Sequence[int],
#     owner_id: str = 'my_username',
#     study_id: str = '1234',
#     **operation_kwargs) -> List[vizier_oss_pb2.EarlyStoppingOperation]:
# def generate_all_four_parameter_specs(**study_spec_kwargs
#                                      ) -> study_pb2.StudySpec:


from vizier.service import resources
from vizier.service import study_pb2
from vizier.service import test_util
from absl.testing import absltest
from absl.testing import parameterized
"""Tests for vizier.service.resources."""




class UtilTest(parameterized.TestCase):

  def setUp(self):
    self.owner_id = 'my_username'
    self.study_id = '12312312'
    self.trial_id = 1
    self.client_id = 'client_0'
    self.operation_number = 5
    super().setUp()

  def test_parsing_correct(self):
    """Tests for correct resource strings only."""
    owner_resource = resources.OwnerResource(self.owner_id)
    same_owner_resource = resources.OwnerResource.from_name(owner_resource.name)
    self.assertEqual(owner_resource, same_owner_resource)

    study_resource = resources.StudyResource(self.owner_id, self.study_id)
    same_study_resource = resources.StudyResource.from_name(study_resource.name)
    self.assertEqual(study_resource, same_study_resource)

    trial_resource = resources.TrialResource(self.owner_id, self.study_id,
                                             self.trial_id)

# Path: vizier/service/resources.py
# def _assert_not_empty(instance: Any, attribute: Any,
#                       value: Optional[Union[str, int]]):
#   def from_name(cls, resource_name: str):
#   def owner_id(self):
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def owner_resource(self) -> OwnerResource:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def make_early_stopping_operation(self, operation_id: str = ''):
#   def study_resource(self) -> StudyResource:
#   def name(self) -> str:
#   def operation_id(self) -> str:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
#   def trial(self) -> TrialResource:
#   def operation_id(self) -> str:
#   def name(self) -> str:
#   def from_name(cls, resource_name: str):
# class OwnerResource:
# class StudyResource:
# class TrialResource:
# class EarlyStoppingOperationResource:
# class SuggestionOperationResource:
# 
# Path: vizier/service/test_util.py
# def generate_study(owner_id: str = 'my_username',
#                    study_id: str = '1234',
#                    display_name: str = 'cifar10',
#                    **study_kwargs) -> study_pb2.Study:
# def generate_trials(trial_id_list: Sequence[int],
#                     owner_id: str = 'my_username',
#                     study_id: str = '1234',
#                     **trial_kwargs) -> List[study_pb2.Trial]:
# def generate_all_states_trials(start_trial_index: int,
#                                owner_id: str = 'my_username',
#                                study_id: str = '1234',
#                                **trial_kwargs) -> List[study_pb2.Trial]:
# def generate_suggestion_operations(
#     operation_numbers: Sequence[int],
#     owner_id: str = 'my_username',
#     client_id: str = 'client0',
#     **operation_kwargs) -> List[operations_pb2.Operation]:
# def generate_early_stopping_operations(
#     trial_id_list: Sequence[int],
#     owner_id: str = 'my_username',
#     study_id: str = '1234',
#     **operation_kwargs) -> List[vizier_oss_pb2.EarlyStoppingOperation]:
# def generate_all_four_parameter_specs(**study_spec_kwargs
#                                      ) -> study_pb2.StudySpec:


# Path: vizier/service/resources_test.py
from vizier.service import resources
from vizier.service import study_pb2
from vizier.service import test_util
from absl.testing import absltest
from absl.testing import parameterized

"""Tests for vizier.service.resources."""




class UtilTest(parameterized.TestCase):

  def setUp(self):
    self.owner_id = 'my_username'
    self.study_id = '12312312'
    self.trial_id = 1
    self.client_id = 'client_0'
    self.operation_number = 5
    super().setUp()

  def test_parsing_correct(self):
    """Tests for correct resource strings only."""
    owner_resource = resources.OwnerResource(self.owner_id)
    same_owner_resource = resources.OwnerResource.from_name(owner_resource.name)
    self.assertEqual(owner_resource, same_owner_resource)

    study_resource = resources.StudyResource(self.owner_id, self.study_id)
    same_study_resource = resources.StudyResource.from_name(study_resource.name)
    self.assertEqual(study_resource, same_study_resource)

    trial_resource = resources.TrialResource(self.owner_id, self.study_id,
                                             self.trial_id)

    same_trial_resource = resources.TrialResource.from_name(trial_resource.name)