def test_assert_error(self): try: compile_debish('apache )', None, None) self.fail('error should happen on invalid expressions') except InputError, error: message = str(error) expected_message = '''apache >>>) Expected end, got ) at character 7''' self.assert_equals(expected_message, message)
def test_or(self): actual = compile_debish('apache | apache2', None, None) expected = oc([ ac([rc(eq, 'pdk', 'name', 'apache')]), ac([rc(eq, 'pdk', 'name', 'apache2')]) ]) self.assert_equals(expected, actual)
def test_name_version(self): actual = compile_debish('apache (=2.0-1)', deb, None) expected = ac([rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', DebianVersion('2.0-1'))]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_untyped_version(self): actual = compile_debish('apache (=2.0-1)', None, None) expected = ac([ rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', '2.0-1') ]) self.assert_equals(expected, actual)
def test_term_with_blob_id(self): actual = compile_debish('apache (=2.0-1)', deb, 'sha-1:aaa') expected = ac([rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', DebianVersion('2.0-1'))]) wrapper = ac([rc(eq, 'pdk', 'blob-id', 'sha-1:aaa'), expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_not_arch(self): actual = compile_debish('apache [!i386 !amd64]', deb, None) expected = ac([rc(eq, 'pdk', 'name', 'apache'), notc(oc([rc(eq, 'deb', 'arch', 'i386'), rc(eq, 'deb', 'arch', 'amd64')]))]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_name_version(self): actual = compile_debish('apache (=2.0-1)', deb, None) expected = ac([ rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', DebianVersion('2.0-1')) ]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_name_arch(self): actual = compile_debish('apache [i386 amd64]', deb, None) expected = ac([ rc(eq, 'pdk', 'name', 'apache'), oc([rc(eq, 'deb', 'arch', 'i386'), rc(eq, 'deb', 'arch', 'amd64')]) ]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_name_other(self): actual = compile_debish('apache {a:b = c dd:ee>=fgh i=j}', deb, None) expected = ac([rc(eq, 'pdk', 'name', 'apache'), ac([rc(eq, 'a', 'b', 'c'), rc(ge, 'dd', 'ee', 'fgh'), rc(eq, 'pdk', 'i', 'j')])]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_term_with_blob_id(self): actual = compile_debish('apache (=2.0-1)', deb, 'sha-1:aaa') expected = ac([ rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', DebianVersion('2.0-1')) ]) wrapper = ac([ rc(eq, 'pdk', 'blob-id', 'sha-1:aaa'), expected, rc(eq, 'pdk', 'type', 'deb') ]) self.assert_equals(wrapper, actual)
def test_name_other(self): actual = compile_debish('apache {a:b = c dd:ee>=fgh i=j}', deb, None) expected = ac([ rc(eq, 'pdk', 'name', 'apache'), ac([ rc(eq, 'a', 'b', 'c'), rc(ge, 'dd', 'ee', 'fgh'), rc(eq, 'pdk', 'i', 'j') ]) ]) wrapper = ac([expected, rc(eq, 'pdk', 'type', 'deb')]) self.assert_equals(wrapper, actual)
def test_name_only(self): actual = compile_debish('apache', None, None) expected = ac([rc(eq, 'pdk', 'name', 'apache')]) self.assert_equals(expected, actual)
def test_marked_condition(self): debish = 'apache (=3) [i386]' condition = compile_debish(debish, deb, None) self.assert_equals(debish, condition.debish)
def test_star2(self): actual = compile_debish('** apache | apache2', None, None) expected = star2c(oc([ac([rc(eq, 'pdk', 'name', 'apache')]), ac([rc(eq, 'pdk', 'name', 'apache2')])])) self.assert_equals(expected, actual)
def test_build_general_debish_ref(self): actual = compile_debish('apache', src, None) expected = ac([rc(eq, 'pdk', 'name', 'apache')]) wrapper = ac([expected, rc(eq, 'pdk', 'role', 'source')]) self.assert_equals(wrapper, actual)
def test_relaxed_relation(self): actual = compile_debish('apache {a:b %= c}', None, None) expected = ac( [rc(eq, 'pdk', 'name', 'apache'), ac([relrc(eq, 'a', 'b', 'c')])]) self.assert_equals(expected, actual)
def test_relaxed_relation(self): actual = compile_debish('apache {a:b %= c}', None, None) expected = ac([rc(eq, 'pdk', 'name', 'apache'), ac([relrc(eq, 'a', 'b', 'c')])]) self.assert_equals(expected, actual)
def test_untyped_version(self): actual = compile_debish('apache (=2.0-1)', None, None) expected = ac([rc(eq, 'pdk', 'name', 'apache'), rc(eq, 'pdk', 'version', '2.0-1')]) self.assert_equals(expected, actual)