changeset 2255:95800dad44d0 beta

fixes for tests on Windows
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 10 May 2012 20:16:04 +0200
parents 8b1a79ad7a42
children 790398822cad
files rhodecode/controllers/files.py rhodecode/tests/functional/test_files.py rhodecode/tests/test_models.py
diffstat 3 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/files.py	Thu May 10 19:52:11 2012 +0200
+++ b/rhodecode/controllers/files.py	Thu May 10 20:16:04 2012 +0200
@@ -48,6 +48,7 @@
 
 from rhodecode.model.repo import RepoModel
 from rhodecode.model.scm import ScmModel
+from rhodecode.model.db import Repository
 
 from rhodecode.controllers.changeset import anchor_url, _ignorews_url,\
     _context_url, get_line_ctx, get_ignore_ws
@@ -168,7 +169,7 @@
         file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path)
 
         response.content_disposition = 'attachment; filename=%s' % \
-            safe_str(f_path.split(os.sep)[-1])
+            safe_str(f_path.split(Repository.url_sep())[-1])
 
         response.content_type = file_node.mimetype
         return file_node.content
--- a/rhodecode/tests/functional/test_files.py	Thu May 10 19:52:11 2012 +0200
+++ b/rhodecode/tests/functional/test_files.py	Thu May 10 20:16:04 2012 +0200
@@ -197,11 +197,13 @@
                                         repo_name=HG_REPO,
                                         fname=fname))
 
-            assert response.status == '200 OK', 'wrong response code'
-            assert response.response._headers.items() == [('Pragma', 'no-cache'),
-                                                  ('Cache-Control', 'no-cache'),
-                                                  ('Content-Type', '%s; charset=utf-8' % info[0]),
-                                                  ('Content-Disposition', 'attachment; filename=%s' % filename), ], 'wrong headers'
+            self.assertEqual(response.status, '200 OK')
+            self.assertEqual(response.response._headers.items(),
+             [('Pragma', 'no-cache'),
+              ('Cache-Control', 'no-cache'),
+              ('Content-Type', '%s; charset=utf-8' % info[0]),
+              ('Content-Disposition', 'attachment; filename=%s' % filename),]
+            )
 
     def test_archival_wrong_ext(self):
         self.log_user()
@@ -212,8 +214,7 @@
             response = self.app.get(url(controller='files', action='archivefile',
                                         repo_name=HG_REPO,
                                         fname=fname))
-            assert 'Unknown archive type' in response.body
-
+            response.mustcontain('Unknown archive type')
 
     def test_archival_wrong_revision(self):
         self.log_user()
@@ -224,7 +225,7 @@
             response = self.app.get(url(controller='files', action='archivefile',
                                         repo_name=HG_REPO,
                                         fname=fname))
-            assert 'Unknown revision' in response.body
+            response.mustcontain('Unknown revision')
 
     #==========================================================================
     # RAW FILE
@@ -236,8 +237,8 @@
                                     revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
                                     f_path='vcs/nodes.py'))
 
-        assert response.content_disposition == "attachment; filename=nodes.py"
-        assert response.content_type == "text/x-python"
+        self.assertEqual(response.content_disposition, "attachment; filename=nodes.py")
+        self.assertEqual(response.content_type, "text/x-python")
 
     def test_raw_file_wrong_cs(self):
         self.log_user()
@@ -277,7 +278,7 @@
                                     revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
                                     f_path='vcs/nodes.py'))
 
-        assert response.content_type == "text/plain"
+        self.assertEqual(response.content_type, "text/plain")
 
     def test_raw_wrong_cs(self):
         self.log_user()
--- a/rhodecode/tests/test_models.py	Thu May 10 19:52:11 2012 +0200
+++ b/rhodecode/tests/test_models.py	Thu May 10 20:16:04 2012 +0200
@@ -5,7 +5,8 @@
 from rhodecode.model.repos_group import ReposGroupModel
 from rhodecode.model.repo import RepoModel
 from rhodecode.model.db import RepoGroup, User, Notification, UserNotification, \
-    UsersGroup, UsersGroupMember, Permission, UsersGroupRepoGroupToPerm
+    UsersGroup, UsersGroupMember, Permission, UsersGroupRepoGroupToPerm,\
+    Repository
 from sqlalchemy.exc import IntegrityError
 from rhodecode.model.user import UserModel
 
@@ -153,24 +154,23 @@
         self.assertTrue(self.__check_path('g2', 'g1'))
 
         # test repo
-        self.assertEqual(r.repo_name, os.path.join('g2', 'g1', r.just_name))
-
+        self.assertEqual(r.repo_name, RepoGroup.url_sep().join(['g2', 'g1', r.just_name]))
 
     def test_move_to_root(self):
         g1 = _make_group('t11')
         Session.commit()
-        g2 = _make_group('t22',parent_id=g1.group_id)
+        g2 = _make_group('t22', parent_id=g1.group_id)
         Session.commit()
 
-        self.assertEqual(g2.full_path,'t11/t22')
+        self.assertEqual(g2.full_path, 't11/t22')
         self.assertTrue(self.__check_path('t11', 't22'))
 
         g2 = self.__update_group(g2.group_id, 'g22', parent_id=None)
         Session.commit()
 
-        self.assertEqual(g2.group_name,'g22')
+        self.assertEqual(g2.group_name, 'g22')
         # we moved out group from t1 to '' so it's full path should be 'g2'
-        self.assertEqual(g2.full_path,'g22')
+        self.assertEqual(g2.full_path, 'g22')
         self.assertFalse(self.__check_path('t11', 't22'))
         self.assertTrue(self.__check_path('g22'))
 
@@ -620,7 +620,7 @@
         # add repo to group
         form_data = {
             'repo_name':HG_REPO,
-            'repo_name_full':os.path.join(self.g1.group_name,HG_REPO),
+            'repo_name_full':RepoGroup.url_sep().join([self.g1.group_name,HG_REPO]),
             'repo_type':'hg',
             'clone_uri':'',
             'repo_group':self.g1.group_id,