def test_upload_download(self): self.args.action = 'upload' clitool.upload(self.args) self.args.action = 'download' clitool.download(self.args) orig_sha256 = ("bc839c0f9195028d375d652e72a5d08d" "293eefd22868493185f084bc4aa61d00") sha256 = hashlib.sha256() with open(self.downloadfile, 'rb') as f: sha256.update(f.read()) new_sha256 = sha256.hexdigest() self.assertEqual(orig_sha256, new_sha256)
def test_download_no_dest(self): self.args.action = 'download' self.args.dest = None filepath = clitool.download(self.args) self.assertTrue(filepath) self.assertTrue(os.path.isfile(filepath)) orig_sha256 = ("bc839c0f9195028d375d652e72a5d08d" "293eefd22868493185f084bc4aa61d00") sha256 = hashlib.sha256() with open(filepath, 'rb') as f: sha256.update(f.read()) new_sha256 = sha256.hexdigest() self.assertEqual(orig_sha256, new_sha256)
def test_download_no_dest(self): self.args.action = 'download' self.args.dest = None filepath = clitool.download(self.args) self.assertTrue(filepath) self.assertTrue(os.path.isfile(filepath)) orig_sha256 = ("bc839c0f9195028d375d652e72a5d08d" "293eefd22868493185f084bc4aa61d00") sha256 = hashlib.sha256() with open(filepath, 'rb') as f: sha256.update(f.read()) new_sha256 = sha256.hexdigest() self.assertEqual(orig_sha256, new_sha256) os.remove(filepath)
def test_download_bad_dest(self): self.args.action = 'download' self.args.dest = 'tests' with self.assertRaises(FileError): clitool.download(self.args)
def test_download_bad_dest(self): self.args.action = 'download' self.args.dest = 'tests' with self.assertRaises(FileError): filepath = clitool.download(self.args)