def setUp(self): user = StorageUser() user.email = '*****@*****.**' user.first_name = 'derek' user.last_name = 'shephard' user.set_password('password') user.save() self.user = user folder = Folder() folder.name = "test" folder.owner = user folder.save() self.folder = folder file = File() file.name = "boop.jpg" file.original_name = "boop.jpg" file.size = 123 file.mime_type = "img/jpg" file.folder = folder file.owner = user file.file = SimpleUploadedFile("file.jpg", b"file_content", content_type="image/jpeg") file.save() self.file = file
def create(self, validated_data): """ Create folder using validated data (validated by serializer) """ folder = Folder() folder.name = validated_data['name'] folder.parent = validated_data['parent'] folder.owner = validated_data['user'] folder.save() return folder
def test_put_folder_detail_success(self): # Create a new folder to act as a new parent for folder_1 folder_3 = Folder() folder_3.name = 'test_folder_3' folder_3.parent = self.folder_root_1 folder_3.owner = self.user_1 folder_3.save() url = '/api/folders/{}/'.format(self.folder_1.id) self.client.force_authenticate(user=self.user_1) data = {'name': 'folder_1a', 'parent': folder_3.id} response = self.client.put(url, data, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual( Folder.objects.get(name='folder_1a').id, self.folder_1.id)
def setUp(self): user_1 = StorageUser() user_1.email = '*****@*****.**' user_1.first_name = 'derek' user_1.last_name = 'shephard' user_1.set_password('password') user_1.save() self.user_1 = user_1 user_2 = StorageUser() user_2.email = '*****@*****.**' user_2.first_name = 'richard' user_2.last_name = 'jones' user_2.set_password('password') user_2.save() self.user_2 = user_2 folder_root_1 = Folder() folder_root_1.name = 'user_1_root' folder_root_1.owner = user_1 folder_root_1.save() self.folder_root_1 = folder_root_1 folder_1 = Folder() folder_1.name = 'test_folder_1' folder_1.parent = folder_root_1 folder_1.owner = user_1 folder_1.save() self.folder_1 = folder_1 folder_2 = Folder() folder_2.name = 'test_folder_2' folder_2.owner = user_2 folder_2.save() self.folder_2 = folder_2
def setUp(self): self.sample_time = models.DateTimeField(auto_now=True) test_user = StorageUser() test_user.first_name = 'John' test_user.last_name = 'Doe' test_user.email = '*****@*****.**' test_user.is_active = True test_user.is_superuser = False test_user.save() self.test_user = test_user self.test_file = SimpleUploadedFile("file.jpg", b"file_content", content_type="image/jpeg") test_folder = Folder() test_folder.name = 'home_folder' test_folder.owner = self.test_user test_folder.save() self.test_folder = test_folder