def test_read_deps(self, mock_json_load): _file = open(os.path.join(settings.SYSTEMJS_CACHE_DIR, 'deps.json'), 'w') _file.write(json.dumps(self._depcache)) self.addCleanup(_file.close) self.addCleanup(lambda: os.remove(_file.name)) mock_json_load.return_value = self._depcache tracer = SystemTracer() # checking reading the hashes hashes = tracer.get_hashes() self.assertEqual( hashes, { 'app/dummy.js': '65d75b61cae058018d3de1fa433a43da', 'app/dependency.js': 'd41d8cd98f00b204e9800998ecf8427e' }) # check reading the depcache for an app depcache = tracer.get_depcache('app/dummy') self.assertEqual( depcache, { 'app/dummy.js': { 'name': 'app/dummy.js', 'timestamp': self.now, 'path': 'app/dummy.js', 'skip': False, }, 'app/dependency.js': { 'name': 'app/dependency.js', 'timestamp': self.now, 'path': 'app/dependency.js', 'skip': False, } }) # check retrieving bundle options bundle_options = tracer.get_bundle_options() self.assertEqual(bundle_options, { 'option1': True, 'option2': False, }) self.assertEqual(mock_json_load.call_count, 1)
def test_read_deps(self, mock_json_load): _file = open(os.path.join(settings.SYSTEMJS_CACHE_DIR, 'deps.json'), 'w') _file.write(json.dumps(self._depcache)) self.addCleanup(_file.close) self.addCleanup(lambda: os.remove(_file.name)) mock_json_load.return_value = self._depcache tracer = SystemTracer() # checking reading the hashes hashes = tracer.get_hashes() self.assertEqual(hashes, { 'app/dummy.js': '65d75b61cae058018d3de1fa433a43da', 'app/dependency.js': 'd41d8cd98f00b204e9800998ecf8427e' }) # check reading the depcache for an app depcache = tracer.get_depcache('app/dummy') self.assertEqual(depcache, { 'app/dummy.js': { 'name': 'app/dummy.js', 'timestamp': self.now, 'path': 'app/dummy.js', 'skip': False, }, 'app/dependency.js': { 'name': 'app/dependency.js', 'timestamp': self.now, 'path': 'app/dependency.js', 'skip': False, } }) # check retrieving bundle options bundle_options = tracer.get_bundle_options() self.assertEqual(bundle_options, { 'option1': True, 'option2': False, }) self.assertEqual(mock_json_load.call_count, 1)