def test_can_cache(self): test_file = self.get_test_loc('cache/package/package.json') from scancode import api package = api.get_package_infos(test_file) file_info = dict(sha1='def') test_dir = self.get_temp_dir() cache = ScanFileCache(test_dir) cache.put_info(path='abc', file_info=file_info) cache.put_scan(path='abc', file_info=file_info, scan_result=package) assert file_info == cache.get_info(path='abc') assert package == cache.get_scan(path='abc', file_info=file_info)
def test_get_package_infos_can_pickle(self): test_file = self.get_test_loc('api/package/package.json') package = api.get_package_infos(test_file) import pickle import cPickle try: _pickled = pickle.dumps(package, pickle.HIGHEST_PROTOCOL) _cpickled = cPickle.dumps(package, pickle.HIGHEST_PROTOCOL) self.fail('pickle.HIGHEST_PROTOCOL used to fail to pickle this data') except: _pickled = pickle.dumps(package) _cpickled = cPickle.dumps(package)
def test_get_package_infos_works_for_maven_pom_dot_xml(self): test_file = self.get_test_loc('api/package/pom.xml') packages = api.get_package_infos(test_file) assert len(packages) == 1 package = packages[0] assert package['version'] == '1.3'