示例#1
0
 def test_compound_field_long(self):
     ms = self.model['model'].copy()
     a = 'xxxxfdgjkdhgsjkfhglhdjghdfhlkgshlfdhjkhfdlkjhjklfdhljkgdfhlkjghjk'
     ms['dimensions']['function']['attributes'][a] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#2
0
 def test_compound_field_long(self):
     ms = self.model['model'].copy()
     a = 'xxxxfdgjkdhgsjkfhglhdjghdfhlkgshlfdhjkhfdlkjhjklfdhljkgdfhlkjghjk'
     ms['dimensions']['function']['attributes'][a] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#3
0
 def test_basic_validate(self):
     try:
         in_ = self.model['model']
         out = validate_model(in_)
         assert len(out) == len(in_), out
     except ValidationError, i:
         assert False, i
示例#4
0
 def test_basic_validate(self):
     try:
         in_ = self.model['model']
         out = validate_model(in_)
         assert len(out) == len(in_), out
     except ValidationError, i:
         assert False, i
示例#5
0
 def test_set_label_attribute(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['label_attribute'] = 'label'
     ms['dimensions']['function']['key_attribute'] = 'name'
     ms = validate_model(ms)
     assert ms['dimensions']['function']['label_attribute'] == 'label'
     assert ms['dimensions']['function']['key_attribute'] == 'name'
示例#6
0
 def test_basic_validate(self):
     try:
         in_ = self.model['model']
         out = validate_model(in_)
         assert len(out) == len(in_), out
     except Invalid, i:
         assert False, i.asdict()
示例#7
0
 def test_set_label_attribute(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['label_attribute'] = 'label'
     ms['dimensions']['function']['key_attribute'] = 'name'
     ms = validate_model(ms)
     assert ms['dimensions']['function']['label_attribute'] == 'label'
     assert ms['dimensions']['function']['key_attribute'] == 'name'
示例#8
0
 def test_basic_validate(self):
     try:
         in_ = self.model['model']
         out = validate_model(in_)
         assert len(out) == len(in_), out
     except Invalid, i:
         assert False, i.asdict()
示例#9
0
文件: dataset.py 项目: trickvi/spendb
def update_model(name):
    dataset = get_dataset(name)
    require.dataset.update(dataset)
    model_data = validate_model(request_data())
    dataset.update_model(model_data)
    dataset.touch()
    db.session.commit()
    return model(name)
示例#10
0
文件: dataset.py 项目: leowmjw/spendb
def update_model(name):
    dataset = get_dataset(name)
    require.dataset.update(dataset)
    model_data = validate_model(request_data())
    dataset.update_model(model_data)
    dataset.touch()
    db.session.commit()
    return model(name)
示例#11
0
def update_model(name):
    dataset = get_dataset(name)
    require.dataset.update(dataset)
    data = request_data()
    if isinstance(data, dict):
        data['fact_table'] = dataset.fact_table.table_name
    dataset.model = validate_model(data)
    db.session.commit()
    return model(name)
示例#12
0
def update_model(name):
    dataset = get_dataset(name)
    require.dataset.update(dataset)
    data = request_data()
    if isinstance(data, dict):
        data['fact_table'] = dataset.fact_table.table_name
    dataset.model = validate_model(data)
    db.session.commit()
    return model(name)
示例#13
0
def get_model(model):
    """ Get and validate the model. If the model doesn't validate
    we exit the program. """
    model = json_of_url(model)

    # Validate the model
    try:
        log.info("Validating model")
        model = validate_model(model)
    except Invalid as i:
        log.error("Errors occured during model validation:")
        for field, error in i.asdict().items():
            log.error("%s: %s", field, error)
        sys.exit(1)
    return model
示例#14
0
 def test_no_measures(self):
     ms = self.model['model']
     ms['measures'] = {}
     validate_model(ms)
示例#15
0
 def test_invalid_name(self):
     ms = self.model['model']
     ms['dimensions']['ba nana'] = ms['dimensions']['function']
     validate_model(ms)
示例#16
0
 def test_from_is_compound(self):
     ms = self.model['model']
     ms['dimensions']['from'] = ms['measures']['cofinance']
     validate_model(ms)
示例#17
0
 def test_invalid_name(self):
     ms = self.model['model']
     ms['dimensions']['ba nana'] = ms['dimensions']['function']
     validate_model(ms)
示例#18
0
 def test_no_measures(self):
     ms = self.model['model']
     ms['measures'] = {}
     validate_model(ms)
示例#19
0
 def test_compound_field_with_dash(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['attributes']['id-col'] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#20
0
 def test_compound_field_has_column(self):
     ms = self.model['model'].copy()
     del ms['dimensions']['function']['attributes']['description']['column']
     validate_model(ms)
示例#21
0
 def test_keep_extra_data(self):
     ms = self.model['model']
     ms['ignore_columns'] = ['huhu']
     os = validate_model(ms)
     assert 'ignore_columns' in os, os.keys()
示例#22
0
 def test_measure_has_column(self):
     ms = self.model['model'].copy()
     del ms['measures']['cofinance']['column']
     validate_model(ms)
示例#23
0
 def test_compound_field_has_column(self):
     ms = self.model['model'].copy()
     del ms['dimensions']['function']['attributes']['description']['column']
     validate_model(ms)
示例#24
0
 def test_compound_field_invalid_name(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['attributes']['ba nanana'] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#25
0
 def test_compound_field_with_dash(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['attributes']['id-col'] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#26
0
 def test_date_has_column(self):
     ms = self.model['model'].copy()
     del ms['dimensions']['time']['attributes']['year']['column']
     validate_model(ms)
示例#27
0
 def test_measure_has_column(self):
     ms = self.model['model'].copy()
     del ms['measures']['cofinance']['column']
     validate_model(ms)
示例#28
0
 def test_date_has_column(self):
     ms = self.model['model'].copy()
     del ms['dimensions']['time']['attributes']['year']['column']
     validate_model(ms)
示例#29
0
 def test_no_dimensions(self):
     ms = self.model['model']
     ms['dimensions'] = {}
     validate_model(ms)
示例#30
0
 def test_compound_field_invalid_name(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['attributes']['ba nanana'] = \
         ms['dimensions']['function']['attributes']['description']
     del ms['dimensions']['function']['attributes']['description']
     validate_model(ms)
示例#31
0
 def test_measure_data_type(self):
     ms = self.model['model'].copy()
     ms['measures']['cofinance']['type'] = 'string'
     validate_model(ms)
示例#32
0
 def test_measure_data_type(self):
     ms = self.model['model'].copy()
     ms['measures']['cofinance']['type'] = 'string'
     validate_model(ms)
示例#33
0
 def test_set_invalid_label_attribute(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['label_attribute'] = 'foo'
     os = validate_model(ms)
     assert False, os['dimensions']
示例#34
0
 def test_set_invalid_label_attribute(self):
     ms = self.model['model'].copy()
     ms['dimensions']['function']['label_attribute'] = 'foo'
     os = validate_model(ms)
     assert False, os['dimensions']
示例#35
0
 def test_keep_extra_data(self):
     ms = self.model['model']
     ms['ignore_columns'] = ['huhu']
     os = validate_model(ms)
     assert 'ignore_columns' in os, os.keys()
示例#36
0
def update_model(name):
    dataset = get_dataset(name)
    require.dataset.update(dataset)
    dataset.data['model'] = validate_model(request_data())
    db.session.commit()
    return model(name)
示例#37
0
 def test_from_is_compound(self):
     ms = self.model['model']
     ms['dimensions']['from'] = ms['measures']['cofinance']
     validate_model(ms)