From 0a427dbd5acbcfee8874c30fb0a1c16473f1b93d Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 19 Nov 2009 16:15:52 +0000 Subject: LP 448319 : Adding tests for translator, properties, constraints and probes, fixing Probe Proxy's uninstall --- (limited to 'tests/propertiestests.py') diff --git a/tests/propertiestests.py b/tests/propertiestests.py index 2494ea6..cb8e884 100644 --- a/tests/propertiestests.py +++ b/tests/propertiestests.py @@ -540,6 +540,62 @@ class TFilePropertyTest(unittest.TestCase): except FileConstraintError: pass +class TResourcePropertyTest(unittest.TestCase): + def test_valid_names(self): + class klass1(TPropContainer): + res = TResourceProperty() + + name1 = "file_" + unicode(uuid.uuid1()) + ".png" + name2 = unicode(uuid.uuid1()) + "_" + unicode(uuid.uuid1()) + ".extension" + name3 = "/home/user/.sugar/_random/new_image1231_" + unicode(uuid.uuid1()).upper() + ".mp3" + name4 = "a_" + unicode(uuid.uuid1()) + name5 = "" + + obj1 = klass1() + + obj1.res = name1 + assert obj1.res == name1, "Could not assign the valid name correctly : %s" % name1 + + obj1.res = name2 + assert obj1.res == name2, "Could not assign the valid name correctly : %s" % name2 + + obj1.res = name3 + assert obj1.res == name3, "Could not assign the valid name correctly : %s" % name3 + + obj1.res = name4 + assert obj1.res == name4, "Could not assign the valid name correctly : %s" % name4 + + obj1.res = name5 + assert obj1.res == name5, "Could not assign the valid name correctly : %s" % name5 + + def test_invalid_names(self): + class klass1(TPropContainer): + res = TResourceProperty() + + bad_name1 = ".jpg" + bad_name2 = "_.jpg" + bad_name3 = "_" + unicode(uuid.uuid1()) + + obj1 = klass1() + + try: + obj1.res = bad_name1 + assert False, "A invalid name was accepted : %s" % bad_name1 + except ResourceConstraintError: + pass + + try: + obj1.res = bad_name2 + assert False, "A invalid name was accepted : %s" % bad_name2 + except ResourceConstraintError: + pass + + try: + obj1.res = bad_name3 + assert False, "A invalid name was accepted : %s" % bad_name3 + except ResourceConstraintError: + pass + class TAddonPropertyTest(unittest.TestCase): def test_wrong_value(self): class klass1(TPropContainer): -- cgit v0.9.1