def test_sharedfile_saved_to_group_shake(self): test_files = os.path.join(os.path.dirname(os.path.dirname(__file__)), "files") file_key = Sourcefile.get_sha1_file_key(test_files + "/1.png") shutil.copyfile("%s/1.png" % (test_files), "/tmp/%s" % (file_key)) #create a new shake group_shake = Shake(user_id=self.user.id, type='group', title='asdf', name='asdf') group_shake.save() a_shared_file = Sharedfile.create_from_file("/tmp/%s" % (file_key), "1.png", file_key, "image/png", self.user.id, group_shake.id) self.assertTrue(group_shake.can_update(self.user.id)) a_shared_file.add_to_shake(self.user.shake()) ssfs = Shakesharedfile.all() for ssf in ssfs: self.assertEqual(ssf.sharedfile_id, a_shared_file.id)
def test_uploading_file_creates_shared_shake_file(self): response = self.upload_test_file() ssf = Shakesharedfile.get("shake_id=%s and sharedfile_id=1", self.user_shake.id) self.assertTrue(ssf)