Ejemplo n.º 1
0
def test_tags():
    jf = reader.Tags()
    assert not jf.tagged_fields
    assert jf.values == {
        "unique",
        "category",
        "name_field",
        "product_url_field",
        "product_price_field",
        "product_price_was_field",
    }
Ejemplo n.º 2
0
    def run_schema_rules(self) -> None:
        if not self.schema:
            return
        self.save_result(
            schema_rules.validate(self.schema, self.source_items.raw))

        tagged_fields = sr.Tags().get(self.schema)
        target_columns = (self.target_items.df.columns.values
                          if self.target_items else None)

        check_tags_result = schema_rules.check_tags(
            self.source_items.df.columns.values, target_columns, tagged_fields)
        self.save_result(check_tags_result)
        if check_tags_result.errors:
            return

        self.run_customized_rules(self.source_items, tagged_fields)
        self.compare_with_customized_rules(self.source_items,
                                           self.target_items, tagged_fields)
Ejemplo n.º 3
0
def test_get_field_tags(tags, field, expected_tags):
    t = reader.Tags()
    t.get_field_tags(tags, field)
    assert t.tagged_fields == expected_tags
Ejemplo n.º 4
0
def test_get_field_tags_fails(tags, exception):
    with pytest.raises(ValueError) as excinfo:
        reader.Tags().get_field_tags(tags, None)
    assert str(excinfo.value) == exception
Ejemplo n.º 5
0
def test_get_tags(schema, expected_tags):
    assert reader.Tags().get(schema) == expected_tags
Ejemplo n.º 6
0
def test_get_tags_fails():
    with pytest.raises(ValueError) as excinfo:
        reader.Tags().get({})
    assert str(excinfo.value) == "The schema does not have 'properties'"