Example #1
0
 def test_setup_data_model_no_schema(self, mock_get, mock_schema):
     from ramses import models
     config = Mock()
     mock_get.return_value = None
     mock_schema.return_value = None
     with pytest.raises(Exception) as ex:
         models.setup_data_model(config, 'foo', 'Bar')
     assert str(ex.value) == 'Missing schema for model `Bar`'
     mock_get.assert_called_once_with('Bar')
     mock_schema.assert_called_once_with('foo')
Example #2
0
 def test_setup_data_model_no_schema(self, mock_get, mock_schema):
     from ramses import models
     config = Mock()
     mock_get.return_value = None
     mock_schema.return_value = None
     with pytest.raises(Exception) as ex:
         models.setup_data_model(config, 'foo', 'Bar')
     assert str(ex.value) == 'Missing schema for model `Bar`'
     mock_get.assert_called_once_with('Bar')
     mock_schema.assert_called_once_with('foo')
Example #3
0
 def test_setup_data_model_existing_model(self, mock_get):
     from ramses import models
     config = Mock()
     mock_get.return_value = 1
     model, auth_model = models.setup_data_model(config, 'foo', 'Bar')
     assert not auth_model
     assert model == 1
     mock_get.assert_called_once_with('Bar')
Example #4
0
 def test_setup_data_model_existing_model(self, mock_get):
     from ramses import models
     config = Mock()
     mock_get.return_value = 1
     model, auth_model = models.setup_data_model(config, 'foo', 'Bar')
     assert not auth_model
     assert model == 1
     mock_get.assert_called_once_with('Bar')
Example #5
0
 def test_setup_data_model_success(self, mock_get, mock_gen, mock_schema):
     from ramses import models
     mock_get.return_value = None
     mock_schema.return_value = {'field1': 'val1'}
     config = config_mock()
     model = models.setup_data_model(config, 'foo', 'Bar')
     mock_get.assert_called_once_with('Bar')
     mock_schema.assert_called_once_with('foo')
     mock_gen.assert_called_once_with(config,
                                      schema={'field1': 'val1'},
                                      model_name='Bar',
                                      raml_resource='foo')
     assert model == mock_gen()
Example #6
0
 def test_setup_data_model_success(self, mock_get, mock_gen, mock_schema):
     from ramses import models
     mock_get.return_value = None
     mock_schema.return_value = {'field1': 'val1'}
     config = config_mock()
     model = models.setup_data_model(config, 'foo', 'Bar')
     mock_get.assert_called_once_with('Bar')
     mock_schema.assert_called_once_with('foo')
     mock_gen.assert_called_once_with(
         config,
         schema={'field1': 'val1'},
         model_name='Bar',
         raml_resource='foo')
     assert model == mock_gen()