Marcin Kuzminski avatar Marcin Kuzminski committed 95800da

fixes for tests on Windows

Comments (0)

Files changed (3)

rhodecode/controllers/files.py

 
 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
         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

rhodecode/tests/functional/test_files.py

                                         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()
             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()
             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
                                     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()
                                     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()

rhodecode/tests/test_models.py

 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
 
         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'))
 
         # 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,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.