Esempio n. 1
0
def jobs(
        draw,
        services=service_generator(),
        parameters=dictionaries(text(), text()),
) -> Job:
    return Job.new(
        draw(services),
        draw(parameters)
    )
Esempio n. 2
0
    def services(draw, db_services=service_generator()) -> Service:
        """

        :param draw: A function provided by hypothesis, that explains how to
         draw from hypothesis strategies
        :param db_services: The strategy used to generate database models
            representing services
        :return: An instance of the model service
        """
        return Service(draw(db_services))
Esempio n. 3
0
    def services(draw, db_services=service_generator()) -> Service:
        """

        :param draw: A function provided by hypothesis, that explains how to
         draw from hypothesis strategies
        :param db_services: The strategy used to generate database models
            representing services
        :return: An instance of the model service
        """
        return Service(draw(db_services))
Esempio n. 4
0
class TestID(TestService):
    """
    Contains unit tests for the ``id`` property of the service
    """
    @given(service_generator())
    def test_get_id(self, db_service: DatabaseService) -> None:
        """
        Tests that a service model takes on the ID of its database model

        :param db_service: A randomly-generated DatabaseService
        """
        service = Service(db_service)
        self.assertEqual(service.id, db_service.id)
Esempio n. 5
0
class TestDescription(TestService):
    """
    Contains unit tests for the ``description`` getter and setter
    """
    @given(text(), service_generator())
    def test_setting_description_changes_models(
            self, description: str, db_service: DatabaseService) -> None:
        """
        Tests that setting the description on the service model class will
        also set the description on the underlying database service

        :param description: The description to set
        :param db_service: The randomly-generated database service
        """
        service = Service(db_service)
        service.description = description
        self.assertEqual(description, service.description)
        self.assertEqual(description, db_service.description)
Esempio n. 6
0
class TestName(TestService):
    """
    Contains unit tests for the ``name`` getter and setter
    """
    @given(text(), service_generator())
    def test_setting_name_changes_the_models(
            self, name: str, db_service: DatabaseService) -> None:
        """
        Tests that setting a name on the service changes the name on the
            underlying database service

        :param name: The new name
        :param db_service: The new database service
        """
        service = Service(db_service)
        service.name = name
        self.assertEqual(name, service.name)
        self.assertEqual(name, db_service.name)
Esempio n. 7
0
class TestJobRegistrationSchema(TestService):
    @given(service_generator())
    def test_job_registration_schema(self,
                                     db_service: DatabaseService) -> None:
        service = Service(db_service)
        self.assertEqual(service.job_registration_schema,
                         db_service.job_registration_schema)

    @given(dictionaries(text(), text()), TestService.services())
    def test_unable_to_set_job_schema(self, new_reg: dict,
                                      service: DatabaseService) -> None:
        """

        Tests that the ``job_registration_schema`` for the service is immutable

        :param new_reg: The registration schema to set
        :param service: The randomly generated service for which the
            property is attempted to be set
        """
        with self.assertRaises(AttributeError):
            service.job_registration_schema = new_reg