def test_rewrite_set(): # c = GenericSetCondition(Field('a'), '==', []) # res = ds._rewrite_generic_set_condition(c) assert_equal( TrueCondition(), ds._rewrite_generic_set_condition( GenericSetCondition(Field('a'), '==', []))) assert_equal( GenericBinaryCondition(Field('a'), '==', "foo"), ds._rewrite_generic_set_condition( GenericSetCondition(Field('a'), '==', ["foo"]))) assert_equal( Or([ GenericBinaryCondition(Field('a'), '==', "foo"), GenericBinaryCondition(Field('a'), '==', "bar") ]), ds._rewrite_generic_set_condition( GenericSetCondition(Field('a'), '==', ["foo", "bar"])))
def test_parse_dim_eq_num(): assert_equal( parse_binary_condition(':dim == 23'), GenericBinaryCondition(TaggedDim(frozenset(), Dim('dim')), '==', 23))
def test_parse_field_eq_ip(): assert_equal(parse_binary_condition('@asdf == 2.3.4.5'), GenericBinaryCondition(Field('asdf'), '==', "2.3.4.5"))
def test_parse_field_eq_star(): assert_equal(parse_binary_condition('@asdf == "*test*"'), GenericBinaryCondition(Field('asdf'), '==', "*test*"))
def test_parse_field_eq_quote(): assert_equal(parse_binary_condition("@asdf == 'asdf'"), GenericBinaryCondition(Field('asdf'), '==', "asdf"))
def test_parse_field_eq_float(): assert_equal(parse_binary_condition('@asdf == 2.03'), GenericBinaryCondition(Field('asdf'), '==', 2.03))
def test_gbc_repr(): c = GenericBinaryCondition(tagged_dim('t:d'), '==', 2) assert_equal( c , eval(repr(c)))
def gbceq(l, r): return GenericBinaryCondition(l, '==', r)
def test_ds_remove_generic_binary_condition_unsupported_op(): c = GenericBinaryCondition(Field('f'), '<>', '23') ds._rewrite_generic_binary_condition(c)
def test_ds_remove_generic_binary_condition(): c = GenericBinaryCondition(Field('f'), '==', '23') r = ds._rewrite_generic_binary_condition(c) assert_equal(r, Equals(Field('f'), '23'))