class TestUniversalCoverageOperator(CoverageOperatorTestCommon):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.sut = UniversalCoverageOperator()

        self.environment_mock.get_sentence_symbol.return_value = Symbol(hash('a'))

    def test_operators_execute_with_some_chance(self):
        self.operator_executes_with_some_chance_scenario()

    def test_given_unknown_terminal_symbol_should_cover_it(self):
        # When:
        result = self.sut.cover(self.cyk_service_mock, self.environment_mock,
                                self.rule_population_mock, self.coordinates)

        # Then:
        assert_that(result, is_(equal_to(Production(
            Detector(self.coordinates),
            TerminalRule(Symbol(hash('U')), Symbol(hash('a')))))))

    def test_if_universal_symbol_unset_in_rule_population_error_should_be_raised(self):
        type(self.rule_population_mock).universal_symbol = PropertyMock(Symbol, return_value=None)

        assert_that(calling(self.sut.cover).with_args(
            self.cyk_service_mock,
            self.environment_mock,
            self.rule_population_mock,
            self.coordinates), raises(InvalidCykConfigurationError))
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.sut = UniversalCoverageOperator()

        self.environment_mock.get_sentence_symbol.return_value = Symbol(hash('a'))