示例#1
0
    def test__update_metadata(self):
        """Test ``_update_metadata`` if metadata has no model_kwargs.

        If ``self._metadata`` has no ``model_kwargs`` in it, this
        method should prepare the ``model_kwargs`` dict and call
        ``self._metadata.set_model_kwargs`` with it.

        Setup:
        - self._metadata.get_model_kwargs that returns None.
        - self.get_distributions that returns a distribution dict.

        Expected Output
        - None

        Side Effects
        - ``self._metadata.set_model_kwargs`` is called with the
          expected dict.
        """
        # Setup
        gaussian_copula = Mock(spec_set=GaussianCopula)
        gaussian_copula._metadata.get_model_kwargs.return_value = dict()
        gaussian_copula._categorical_transformer = 'a_categorical_transformer_value'
        gaussian_copula._default_distribution = 'a_distribution'
        gaussian_copula.get_distributions.return_value = {
            'foo': 'copulas.univariate.gaussian.GaussianUnivariate'
        }

        # Run
        out = GaussianCopula._update_metadata(gaussian_copula)

        # Asserts
        assert out is None
        expected_kwargs = {
            'field_distributions': {
                'foo': 'copulas.univariate.gaussian.GaussianUnivariate'
            },
            'default_distribution': 'a_distribution',
            'categorical_transformer': 'a_categorical_transformer_value',
        }
        gaussian_copula._metadata.set_model_kwargs.assert_called_once_with(
            'GaussianCopula', expected_kwargs)
示例#2
0
    def test__update_metadata_existing_model_kargs(self):
        """Test ``_update_metadata`` if metadata already has model_kwargs.

        If ``self._metadata`` already has ``model_kwargs`` in it, this
        method should do nothing.

        Setup:
        - self._metadata.get_model_kwargs that returns a kwargs dict

        Expected Output
        - None

        Side Effects
        - ``self._metadata.set_model_kwargs`` is not called.
        """
        # Setup
        gaussian_copula = Mock(spec_set=GaussianCopula)

        # Run
        out = GaussianCopula._update_metadata(gaussian_copula)

        # Asserts
        assert out is None
        assert not gaussian_copula._metadata.set_model_kwargs.called