fix tests on windows
This commit is contained in:
		
							parent
							
								
									49ff066a12
								
							
						
					
					
						commit
						c7434cb75b
					
				
					 4 changed files with 25 additions and 22 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,6 @@ debug = false
 | 
			
		|||
api_key = 1090a6ae-855f-4be7-b8fb-3edbaf1aa3ec
 | 
			
		||||
[git]
 | 
			
		||||
submodules_disabled =
 | 
			
		||||
  this/path/does/not/exist
 | 
			
		||||
  git/asubmodule
 | 
			
		||||
  that/other/path
 | 
			
		||||
  this[\\/]path[\\/]does[\\/]not[\\/]exist
 | 
			
		||||
  git[\\/]asubmodule
 | 
			
		||||
  that[\\/]other[\\/]path
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ debug = false
 | 
			
		|||
api_key = 1090a6ae-855f-4be7-b8fb-3edbaf1aa3ec
 | 
			
		||||
[git]
 | 
			
		||||
submodules_disabled =
 | 
			
		||||
  this/path/does/not/exist
 | 
			
		||||
  this[\\/]path[\\/]does[\\/]not[\\/]exist
 | 
			
		||||
  \(invalid regex)
 | 
			
		||||
  git/asubmodule
 | 
			
		||||
  that/other/path
 | 
			
		||||
  git[\\/]asubmodule
 | 
			
		||||
  that[\\/]other[\\/]path
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,10 +8,12 @@ from wakatime.packages.requests.models import Response
 | 
			
		|||
 | 
			
		||||
import logging
 | 
			
		||||
import os
 | 
			
		||||
import platform
 | 
			
		||||
import time
 | 
			
		||||
import shutil
 | 
			
		||||
from testfixtures import log_capture
 | 
			
		||||
from . import utils
 | 
			
		||||
from .utils import unittest
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class LoggingTestCase(utils.TestCase):
 | 
			
		||||
| 
						 | 
				
			
			@ -81,6 +83,7 @@ class LoggingTestCase(utils.TestCase):
 | 
			
		|||
            self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
 | 
			
		||||
            logs.check()
 | 
			
		||||
 | 
			
		||||
    @unittest.skipIf(platform.system() == 'Windows', 'Windows file issue')
 | 
			
		||||
    @log_capture()
 | 
			
		||||
    def test_log_file_location_can_be_set_from_env_variable(self, logs):
 | 
			
		||||
        logging.disable(logging.NOTSET)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
    def test_heartbeat_discarded_from_400_response(self):
 | 
			
		||||
        with NamedTemporaryFile() as fh:
 | 
			
		||||
| 
						 | 
				
			
			@ -137,31 +137,31 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                body = calls[0][0][0].body
 | 
			
		||||
                data = json.loads(body)[0]
 | 
			
		||||
                self.assertEquals(data.get('entity'), os.path.abspath(entity1))
 | 
			
		||||
                self.assertPathsEqual(data.get('entity'), os.path.abspath(entity1))
 | 
			
		||||
                self.assertEquals(data.get('project'), project1)
 | 
			
		||||
                self.assertEquals(u(int(data.get('time'))), now1)
 | 
			
		||||
 | 
			
		||||
                body = calls[1][0][0].body
 | 
			
		||||
                data = json.loads(body)[0]
 | 
			
		||||
                self.assertEquals(data.get('entity'), os.path.abspath(entity2))
 | 
			
		||||
                self.assertPathsEqual(data.get('entity'), os.path.abspath(entity2))
 | 
			
		||||
                self.assertEquals(data.get('project'), project2)
 | 
			
		||||
                self.assertEquals(u(int(data.get('time'))), now2)
 | 
			
		||||
 | 
			
		||||
                body = calls[2][0][0].body
 | 
			
		||||
                data = json.loads(body)[0]
 | 
			
		||||
                self.assertEquals(data.get('entity'), os.path.abspath(entity3))
 | 
			
		||||
                self.assertPathsEqual(data.get('entity'), os.path.abspath(entity3))
 | 
			
		||||
                self.assertEquals(data.get('project'), project3)
 | 
			
		||||
                self.assertEquals(u(int(data.get('time'))), now3)
 | 
			
		||||
 | 
			
		||||
                body = calls[3][0][0].body
 | 
			
		||||
                data = json.loads(body)[0]
 | 
			
		||||
                self.assertEquals(data.get('entity'), os.path.abspath(entity1))
 | 
			
		||||
                self.assertPathsEqual(data.get('entity'), os.path.abspath(entity1))
 | 
			
		||||
                self.assertEquals(data.get('project'), project1)
 | 
			
		||||
                self.assertEquals(u(int(data.get('time'))), now1)
 | 
			
		||||
 | 
			
		||||
                body = calls[3][0][0].body
 | 
			
		||||
                data = json.loads(body)[1]
 | 
			
		||||
                self.assertEquals(data.get('entity'), os.path.abspath(entity2))
 | 
			
		||||
                self.assertPathsEqual(data.get('entity'), os.path.abspath(entity2))
 | 
			
		||||
                self.assertEquals(data.get('project'), project2)
 | 
			
		||||
                self.assertEquals(u(int(data.get('time'))), now2)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -238,15 +238,15 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
                        self.assertSessionCacheSaved()
 | 
			
		||||
 | 
			
		||||
                        queue = Queue(None, None)
 | 
			
		||||
                        self.assertEquals(queue._get_db_file(), fh.name)
 | 
			
		||||
                        self.assertPathsEqual(queue._get_db_file(), fh.name)
 | 
			
		||||
                        saved_heartbeats = next(queue.pop_many())
 | 
			
		||||
                        self.assertNothingPrinted()
 | 
			
		||||
                        self.assertNothingLogged(logs)
 | 
			
		||||
 | 
			
		||||
                        # make sure only heartbeats with error code responses were saved
 | 
			
		||||
                        self.assertEquals(sum(1 for x in saved_heartbeats), 2)
 | 
			
		||||
                        self.assertEquals(saved_heartbeats[0].entity, os.path.realpath(os.path.join(tempdir, entities[1])))
 | 
			
		||||
                        self.assertEquals(saved_heartbeats[1].entity, os.path.realpath(os.path.join(tempdir, entities[3])))
 | 
			
		||||
                        self.assertPathsEqual(saved_heartbeats[0].entity, os.path.realpath(os.path.join(tempdir, entities[1])))
 | 
			
		||||
                        self.assertPathsEqual(saved_heartbeats[1].entity, os.path.realpath(os.path.join(tempdir, entities[3])))
 | 
			
		||||
 | 
			
		||||
    @log_capture()
 | 
			
		||||
    def test_offline_heartbeats_sent_after_partial_success_from_bulk_response(self, logs):
 | 
			
		||||
| 
						 | 
				
			
			@ -467,7 +467,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertNothingPrinted()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
    def test_get_handles_exception_on_connect(self):
 | 
			
		||||
        with NamedTemporaryFile() as fh:
 | 
			
		||||
| 
						 | 
				
			
			@ -497,7 +497,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
    def test_push_handles_exception_on_connect(self):
 | 
			
		||||
        with NamedTemporaryFile() as fh:
 | 
			
		||||
| 
						 | 
				
			
			@ -673,7 +673,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
                self.assertNothingPrinted()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -737,7 +737,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                    queue = Queue(None, None)
 | 
			
		||||
                    saved_heartbeat = queue.pop()
 | 
			
		||||
                    self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                    self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                    self.assertEquals(u(language), saved_heartbeat['language'])
 | 
			
		||||
                    self.assertEquals(u(project), saved_heartbeat['project'])
 | 
			
		||||
                    self.assertEquals(u(branch), saved_heartbeat['branch'])
 | 
			
		||||
| 
						 | 
				
			
			@ -763,7 +763,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
                self.assertNothingPrinted()
 | 
			
		||||
                expected = 'JSONDecodeError'
 | 
			
		||||
| 
						 | 
				
			
			@ -791,7 +791,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
                self.assertNothingPrinted()
 | 
			
		||||
                expected = 'TypeError'
 | 
			
		||||
| 
						 | 
				
			
			@ -819,7 +819,7 @@ class OfflineQueueTestCase(TestCase):
 | 
			
		|||
 | 
			
		||||
                queue = Queue(None, None)
 | 
			
		||||
                saved_heartbeat = queue.pop()
 | 
			
		||||
                self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
                self.assertPathsEqual(os.path.realpath(entity), saved_heartbeat['entity'])
 | 
			
		||||
 | 
			
		||||
                self.assertNothingPrinted()
 | 
			
		||||
                expected = 'IndexError'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue