Пример #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
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
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)