gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r156240 - in gump/branches/Gump3/pygump/python/gump: model/__init__.py test/testModel.py
Date Sat, 05 Mar 2005 13:54:29 GMT
Author: leosimons
Date: Sat Mar  5 05:54:27 2005
New Revision: 156240

URL: http://svn.apache.org/viewcvs?view=rev&rev=156240
Log:
More work on solidifying model using assertions, and another trailing comma bug fixed.

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=156239&r2=156240
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Sat Mar  5 05:54:27 2005
@@ -150,8 +150,8 @@
         
         - all of the properties a Repository has
         - url      -- the address of the svn repository
-        TODO: - user     -- the cvs user to login as
-        TODO: - password -- the cvs password to login with
+        TODO: - user     -- the svn user to login as
+        TODO: - password -- the svn password to login with
     """
     def __init__(self,
                  workspace,
@@ -163,9 +163,10 @@
                  redistributable = False,
                  user = None,
                  password = None):
+        assert isinstance(url, str)
         Repository.__init__(self, workspace, name, title, home_page, cvsweb, redistributable)
         self.url      = url
-        self.user     = user,
+        self.user     = user
         self.password = password
 
 #TODO: class PerforceRepository
@@ -187,6 +188,8 @@
                  name,
                  url = None,
                  description = None):
+        assert isinstance(repository, Repository)
+        assert isinstance(name, str)
         self.repository  = repository
         self.name        = name
         self.url         = url
@@ -195,6 +198,10 @@
         self.projects = {}
 
     def add_project(self, project):
+        assert isinstance(project, Project)
+        assert not self.projects.has_key(project.name)
+        assert self == project.module
+        
         self.projects[project.name] = project
 
 class CvsModule(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=156239&r2=156240
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testModel.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testModel.py Sat Mar  5 05:54:27 2005
@@ -27,6 +27,8 @@
 from gump.model import Module
 from gump.model import CvsRepository
 from gump.model import CVS_METHOD_PSERVER
+from gump.model import SvnRepository
+from gump.model import Project
 
 class ModelTestCase(TestCase):
     def setUp(self):
@@ -160,6 +162,77 @@
         r = CvsRepository(w,name,hostname,path)
         self.assertEqual(":pserver:cvs.somewhere.org:/some/cvs/location", r.to_url())
 
+    def test_svn_repository(self):
+        wname = "blah"
+        w = Workspace(wname)
+        name = "booh"
+        url = "http://svn.somewhere.org/some/svn/repo"
+        title = "t"
+        home_page = "h"
+        cvsweb = "c"
+        redistributable = True
+        user = "anonymous"
+        password = "blah"
+        
+        r = SvnRepository(w,name,url,title,home_page,cvsweb,redistributable,user,password)
+        self.assertEqual(w, r.workspace)
+        self.assertEqual(name, r.name)
+        self.assertEqual(url, r.url)
+        self.assertEqual(title, r.title)
+        self.assertEqual(home_page, r.home_page)
+        self.assertEqual(cvsweb, r.cvsweb)
+        self.assertEqual(redistributable, r.redistributable)
+        self.assertEqual(user, r.user)
+        self.assertEqual(password, r.password)
+        self.assertEqual({}, r.modules)
+        
+        r = SvnRepository(w,name,url,user=user)
+        self.assertEqual(user, r.user)
+        r = SvnRepository(w,name,url,password=password)
+        self.assertEqual(password, r.password)
+        
+        self.assertRaises(AssertionError, SvnRepository, w, name, w)
+    
+    def test_module(self):
+        wname = "blah"
+        w = Workspace(wname)
+        rname = "booh"
+        r = Repository(w,rname)
+        
+        url = "http://www.somewhere.org/bweh/"
+        description = "Bweh is foo bar blah."
+        
+        name = "bweh"
+        m = Module(r,name,url,description)
+        self.assertEqual(r, m.repository)
+        self.assertEqual(name,m.name)
+        self.assertEqual(url,m.url)
+        self.assertEqual(description,m.description)
+        self.assertEqual({}, m.projects)
+        
+        self.assertRaises(AssertionError, Module, None, name)
+        self.assertRaises(AssertionError, Module, name, None)
+        self.assertRaises(AssertionError, Module, "wrong", name)
+        self.assertRaises(AssertionError, Module, r, r)
+        
+        m = Module(r,name,url=url)
+        self.assertEqual(url,m.url)
+        m = Module(r,name,description=description)
+        self.assertEqual(description, description)
+        
+        m = Module(r, name)
+        pname = "blaat"
+        p = Project(m,pname)
+        m.add_project(p)
+        self.assertEqual(p,m.projects[pname])
+        self.assertEqual(1,len(m.projects))
+        
+        self.assertRaises(AssertionError, m.add_project, None)
+        self.assertRaises(AssertionError, m.add_project, "blaaaa")
+        self.assertRaises(AssertionError, m.add_project, p)
+        self.assertEqual(1,len(m.projects))
+        
+        
 
 # this is used by testrunner.py to determine what tests to run
 def test_suite():



Mime
View raw message