예제 #1
0
파일: test_sdv.py 프로젝트: zyteka/SDV
    def test_sample_not_fitted(self):
        """Check that the sample raise an exception when is not fitted."""
        # Setup
        sdv = SDV()

        # Run
        with pytest.raises(NotFittedError):
            sdv.sample('DEMO', 5)
예제 #2
0
    def test_sample_not_fitted(self):
        """Check that the sample raise an exception when is not fitted."""
        # Setup
        sdv = Mock()
        sdv.sampler = None

        # Run
        with pytest.raises(NotFittedError):
            SDV.sample(sdv, 'DEMO', 5)
예제 #3
0
    def test_sample_not_fitted(self):
        """Check that the sample raise an exception when is not fitted."""
        # Run and asserts
        sdv = Mock()
        sdv.sampler = None
        table_name = 'DEMO'
        num_rows = 5

        with pytest.raises(NotFittedError):
            SDV.sample(sdv, table_name, num_rows)
예제 #4
0
파일: test_sdv.py 프로젝트: zyteka/SDV
    def test_sample_fitted(self):
        """Check that the sample is called."""
        # Sample
        sdv = Mock()
        sdv._model_instance.sample.return_value = 'test'

        # Run
        result = SDV.sample(sdv, 'DEMO', 5)

        # Asserts
        assert result == 'test'
        sdv._model_instance.sample.assert_called_once_with(
            'DEMO', 5, sample_children=True, reset_primary_keys=False)
예제 #5
0
    def test_sample_fitted(self):
        """Check that the sample is called."""
        # Run
        sdv = Mock()
        table_name = 'DEMO'
        num_rows = 5
        sdv.sampler.sample.return_value = 'test'

        result = SDV.sample(sdv, table_name, num_rows)

        # Asserts
        sdv.sampler.sample.assert_called_once_with('DEMO',
                                                   5,
                                                   sample_children=True,
                                                   reset_primary_keys=False)

        assert result == 'test'