gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r156236 - in gump/branches/Gump3/pygump/python/gump: model/__init__.py test/testExample.py test/testModel.py
Date Sat, 05 Mar 2005 09:34:31 GMT
Author: leosimons
Date: Sat Mar  5 01:34:29 2005
New Revision: 156236

URL: http://svn.apache.org/viewcvs?view=rev&rev=156236
Log:
Work on the model. Found a few bugs and inconsistencies in starting on the tests.

Modified:
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/test/testExample.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=156235&r2=156236
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Sat Mar  5 01:34:29 2005
@@ -52,6 +52,7 @@
     def add_repository(self, repository):
         assert isinstance(repository, Repository)
         assert not self.repositories.has_key(repository.name)
+        assert self == repository.workspace
         
         self.repositories[repository.name] = repository
 
@@ -87,10 +88,12 @@
         self.redistributable = redistributable
 
         self.modules={}
-        
-        workspace.add_repository(self)
 
     def add_module(self, module):
+        assert isinstance(module, Module)
+        assert not self.modules.has_key(module.name)
+        assert self == module.repository
+        
         self.modules[module.name] = module
     
 
@@ -121,19 +124,21 @@
                  method = CVS_METHOD_PSERVER,
                  user = None,
                  password = None):
+        assert isinstance(hostname,str)
+        assert isinstance(path,str)
         Repository.__init__(self, workspace, name, title, home_page, cvsweb, redistributable)
         
         self.hostname = hostname
-        self.path     = path,
-        self.method   = method,
-        self.user     = user,
+        self.path     = path
+        self.method   = method
+        self.user     = user
         self.password = password
     
     def to_url(self):
         url = ":%s:" % self.method
         if self.user:
-            url = "%s%s@" % (url, tuple(self.user)[0]) #TODO figure out where on earth this
becomes a tuple!!!
-        url = "%s%s:%s" % (url, self.hostname, tuple(self.path)[0])
+            url = "%s%s@" % (url, self.user)
+        url = "%s%s:%s" % (url, self.hostname, self.path)
         
         return url
             

Modified: gump/branches/Gump3/pygump/python/gump/test/testExample.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testExample.py?view=diff&r1=156235&r2=156236
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testExample.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testExample.py Sat Mar  5 01:34:29 2005
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__copyright__ = "Copyright (c) 2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
 """

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=156235&r2=156236
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testModel.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testModel.py Sat Mar  5 01:34:29 2005
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright 2004-2005 The Apache Software Foundation
+# Copyright 2005 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -14,45 +14,151 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__copyright__ = "Copyright (c) 2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
 import unittest
+from unittest import TestCase
 
-from gump.test.mockobjects import *
-from gump.model import Error, Workspace, ModelObject, Repository
+from gump.model import Error
+from gump.model import ModelObject
+from gump.model import Workspace
+from gump.model import Repository
+from gump.model import Module
+from gump.model import CvsRepository
+from gump.model import CVS_METHOD_PSERVER
 
-class ModelTestCase(unittest.TestCase):
+class ModelTestCase(TestCase):
     def setUp(self):
+        # initialize tests here
         pass
     
-    def testError(self):
-        error = Error()
+    def tearDown(self):
+        # clean up after tests here
+        pass
+    
+    def test_error(self):
+        e = Error()
         try:
-            raise error
+            raise e
         except:
             pass
     
-    def testModelObject(self):
-        obj = ModelObject()
+    def test_model_object(self):
+        m = ModelObject()
     
-    def testWorkspace(self):
-        w = Workspace("blah")
-        self.assertEquals("blah", w.name)
-        self.assertEquals({}, w.repositories)
-        self.assertEquals({}, w.modules)
-        self.assertEquals({}, w.projects)
-        self.assertEquals([], w.dependencies)
-        
-        r = Repository(w, "blahblah")
-        self.assertEquals(w.repositories["blahblah"], r)
-        self.assertEquals(1, len(w.repositories))
+    def test_workspace(self):
+        name = "blah"
+        w = Workspace(name)
+        self.assertEqual(name, w.name)
+        self.assertEqual({}, w.repositories)
+        self.assertEqual({}, w.modules)
+        self.assertEqual({}, w.projects)
+        self.assertEqual([], w.dependencies)
         
         self.assertRaises(AssertionError, Workspace, None)
-        self.assertRaises(AssertionError, Workspace, r)
+        
+        r = Repository(w, "booh")
+        w.add_repository(r)
+        self.assertEqual(r, w.repositories["booh"])
+        self.assertEqual(1, len(w.repositories))
+        
+        self.assertRaises(AssertionError, w.add_repository, r)
         self.assertRaises(AssertionError, w.add_repository, None)
         self.assertRaises(AssertionError, w.add_repository, "blah")
-        self.assertRaises(AssertionError, Repository, w, "blahblah")
+        self.assertEqual(1, len(w.repositories))
+        
+        w2 = Workspace("blah2")
+        r2 = Repository(w2, "booh2")
+        self.assertRaises(AssertionError,w.add_repository,r2)
+    
+    def test_repository(self):
+        wname = "blah"
+        w = Workspace(wname)
+        name = "booh"
+        title = "t"
+        home_page = "h"
+        cvsweb = "c"
+        redistributable = True
+        
+        r = Repository(w,name,title,home_page,cvsweb,redistributable)
+        self.assertEqual(w, r.workspace)
+        self.assertEqual(name, r.name)
+        self.assertEqual(title, r.title)
+        self.assertEqual(home_page, r.home_page)
+        self.assertEqual(cvsweb, r.cvsweb)
+        self.assertEqual(redistributable, r.redistributable)
+        self.assertEqual({}, r.modules)
+        
+        r = Repository(w,name,title=title)
+        self.assertEqual(title, r.title)
+        r = Repository(w,name,home_page=home_page)
+        self.assertEqual(home_page, r.home_page)
+        r = Repository(w,name,cvsweb=cvsweb)
+        self.assertEqual(cvsweb, r.cvsweb)
+        r = Repository(w,name,redistributable=redistributable)
+        self.assertEqual(redistributable, r.redistributable)
+        
+        self.assertRaises(AssertionError, Repository, "test", name)
+        self.assertRaises(AssertionError, Repository, "test", w)
+        
+        r = Repository(w,name)
+        mname="bweh"
+        m = Module(r,mname)
+        r.add_module(m)
+        self.assertEqual(m,r.modules["bweh"])
+        self.assertEqual(1,len(r.modules))
+        self.assertRaises(AssertionError, r.add_module, None)
+        self.assertRaises(AssertionError, r.add_module, "bweh")
+        self.assertRaises(AssertionError, r.add_module, m)
+        self.assertEqual(1,len(r.modules))
+        
+        r2 = Repository(w,"booh2")
+        m2 = Module(r2,"bweh2")
+        self.assertRaises(AssertionError, r.add_module, m2)
+    
+    def test_cvs_repository(self):
+        wname = "blah"
+        w = Workspace(wname)
+        name = "booh"
+        hostname = "cvs.somewhere.org"
+        path = "/some/cvs/location"
+        title = "t"
+        home_page = "h"
+        cvsweb = "c"
+        redistributable = True
+        method = CVS_METHOD_PSERVER
+        user = "anonymous"
+        password = "blah"
+        
+        r = CvsRepository(w,name,hostname,path,title,home_page,cvsweb,redistributable,method,user,password)
+        self.assertEqual(w, r.workspace)
+        self.assertEqual(name, r.name)
+        self.assertEqual(hostname,r.hostname)
+        self.assertEqual(path,r.path)
+        self.assertEqual(title, r.title)
+        self.assertEqual(home_page, r.home_page)
+        self.assertEqual(cvsweb, r.cvsweb)
+        self.assertEqual(redistributable, r.redistributable)
+        self.assertEqual(method, r.method)
+        self.assertEqual(user, r.user)
+        self.assertEqual(password, r.password)
+        self.assertEqual({}, r.modules)
+        
+        r = CvsRepository(w,name,hostname,path,method=method)
+        self.assertEqual(method, r.method)
+        r = CvsRepository(w,name,hostname,path,user=user)
+        self.assertEqual(user, r.user)
+        r = CvsRepository(w,name,hostname,path,password=password)
+        self.assertEqual(password, r.password)
+        
+        self.assertRaises(AssertionError, CvsRepository, w, name, w, path)
+        self.assertRaises(AssertionError, CvsRepository, w, name, hostname, w)
+
+        r = CvsRepository(w,name,hostname,path,title,home_page,cvsweb,redistributable,"blah",user,password)
+        self.assertEqual(":blah:anonymous@cvs.somewhere.org:/some/cvs/location", r.to_url())
+        r = CvsRepository(w,name,hostname,path)
+        self.assertEqual(":pserver:cvs.somewhere.org:/some/cvs/location", r.to_url())
 
 
 # this is used by testrunner.py to determine what tests to run
@@ -61,4 +167,4 @@
 
 # this allows us to run this test by itself from the commandline
 if __name__ == '__main__':
-    unittest.main()
+    unittest.main()
\ No newline at end of file



Mime
View raw message