You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/02/08 20:28:47 UTC

svn commit: r152925 - in gump/branches/Gump3/pygump/python/gump: model/__init__.py test/testModel.py

Author: leosimons
Date: Tue Feb  8 11:28:46 2005
New Revision: 152925

URL: http://svn.apache.org/viewcvs?view=rev&rev=152925
Log:
Experiment a little with increased type safety using assertions. In addition, make repositories add themselves to workspaces as an experiment. Should we implement that across the board?

Modified:
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/test/testModel.py

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?view=diff&r1=152924&r2=152925
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Tue Feb  8 11:28:46 2005
@@ -41,6 +41,8 @@
         - dependencies -- list of all dependencies between projects
     """
     def __init__(self, name):
+        assert isinstance(name, str)
+    
         self.name = name
         self.repositories = {}
         self.modules = {}
@@ -48,6 +50,9 @@
         self.dependencies = []
     
     def add_repository(self, repository):
+        assert isinstance(repository, Repository)
+        assert not self.repositories.has_key(repository.name)
+        
         self.repositories[repository.name] = repository
 
 class Repository(ModelObject):
@@ -71,6 +76,9 @@
                  home_page = None,
                  cvsweb = None,
                  redistributable = False):
+        assert isinstance(workspace, Workspace)
+        assert isinstance(name, str)
+        
         self.workspace       = workspace
         self.name            = name
         self.title           = title
@@ -79,6 +87,8 @@
         self.redistributable = redistributable
 
         self.modules={}
+        
+        workspace.add_repository(self)
 
     def add_module(self, module):
         self.modules[module.name] = module

Modified: gump/branches/Gump3/pygump/python/gump/test/testModel.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testModel.py?view=diff&r1=152924&r2=152925
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testModel.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testModel.py Tue Feb  8 11:28:46 2005
@@ -45,10 +45,14 @@
         self.assertEquals([], w.dependencies)
         
         r = Repository(w, "blahblah")
-        self.assertEquals({}, w.repositories)
-        w.add_repository(r)
         self.assertEquals(w.repositories["blahblah"], r)
         self.assertEquals(1, len(w.repositories))
+        
+        self.assertRaises(AssertionError, Workspace, None)
+        self.assertRaises(AssertionError, Workspace, r)
+        self.assertRaises(AssertionError, w.add_repository, None)
+        self.assertRaises(AssertionError, w.add_repository, "blah")
+        self.assertRaises(AssertionError, Repository, w, "blahblah")
 
 
 # this is used by testrunner.py to determine what tests to run