Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/propertiestests.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-12-01 20:11:43 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-12-01 20:11:43 (GMT)
commit2c8fe66c0f7490c8aaaae27b4977b987001c6b71 (patch)
tree32d4ce390d853fb5a8405e71cfb37b6b52988e3b /tests/propertiestests.py
parentb7586af9d127e7954674d13ea185a0e84d197c37 (diff)
parent50ec9ae6ebc7ecc088b5e0a6b79688a717271955 (diff)
Merge branch 'master' of git://git.sugarlabs.org/tutorius/simpoirs-clone
Conflicts: src/extensions/tutoriusremote.py tutorius/TProbe.py tutorius/creator.py
Diffstat (limited to 'tests/propertiestests.py')
-rw-r--r--tests/propertiestests.py56
1 files changed, 56 insertions, 0 deletions
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):