def test_hashes_match(self, mock_json_load): _file = open(os.path.join(settings.SYSTEMJS_CACHE_DIR, 'deps.json'), 'w') self.addCleanup(_file.close) self.addCleanup(lambda: os.remove(_file.name)) mock_json_load.return_value = self._depcache tracer = SystemTracer() dep_tree = { 'app/dummy.js': { 'name': 'app/dummy.js', 'timestamp': self.now, 'path': 'app/dummy.js', }, 'app/dependency.js': { 'name': 'app/dependency.js', 'timestamp': self.now, 'path': 'app/dependency.js', } } self.assertTrue(tracer.hashes_match(dep_tree)) # mock the hashes to return different result with patch.object(tracer, 'get_hashes') as mocked_hashes: mocked_hashes.return_value = { 'app/dummy.js': 'hash.app.dummy.js', 'app/dependency.js': 'hash.app.dependency.js', } self.assertFalse(tracer.hashes_match(dep_tree))