示例#1
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test the image is saved in correct location"""
        uuid = "test-uuid"
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, "myimage.jpg")

        exp_path = f"uploads/recipe/{uuid}.jpg"
        self.assertEqual(file_path, exp_path)
示例#3
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myImage.jpg')

        exp_path = f'upload/recipe/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
 def test_recipe_file_name_uuid(self,mock_uuid):
     """ Test that the image is saved in the correct location """
     uuid = 'test-uuid'
     mock_uuid.return_value = uuid
     file_path = models.recipe_image_file_path(None,'myimage.jpg')
     media_path = os.path.join(BASE_DIR,'media')
     exp_path = media_path + '{uuid}.jpg'
     self.assertEqual(file_path,exp_path)
    def test_for_image_save(self, mock_uuid):
        """Test for image is saved in correct loaction"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = recipe_image_file_path(None, 'test.jpg')

        expt_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, expt_path)
示例#6
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        '''Test that image is saved in the correct values'''
        uuid = 'test_uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        expected_path = f'upload/recipes/{uuid}.jpg'
        self.assertEqual(file_path, expected_path)
示例#7
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test if file name changes as expectes"""
        uuid = 'test_uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'messi.png')

        exp_path = f'/uploads/recipe/{uuid}.png'
        self.assertEqual(file_path, exp_path)
示例#8
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Tes save image di lokasi yang benar"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)
示例#9
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """test that image is saved in the correct location"""
        uuid = '45246-46236-r4563-gfd4346'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        expected_file_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, expected_file_path)
示例#10
0
    def test_test_filename_uuid(self, mock_uuid):
        uuid = "test-uuid"
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, "myimage.jpg")

        exp_path = f"upload/recipe/{uuid}.jpg"

        self.assertEqual(file_path, exp_path)
示例#11
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """test that image is saved to right location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        fpath = models.recipe_image_file_path(None, 'myimage.jpg')
        expected_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(str(fpath), expected_path)
示例#12
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """imageが正しい場所に保存されるかのテスト"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)
示例#13
0
    def test_recipe_filename_uuid(self, mock_uuid):
        '''Test, image is saved in the correct location with correct format'''
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid

        file_path = models.recipe_image_file_path(None, 'my_image.jpg')
        expected_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, expected_path)
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test to change the file name of a file"""
        uuid = 'test_uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
示例#15
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Testea que la imagen se guarde en la ubicacion correcta"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
示例#16
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """Test that image is save in correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = recipe_image_file_path(instance=None,
                                           filename='MyImage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)
示例#17
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """TEST THAT IMAGE IS SAVED TO THE CORRECT LOCATION"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid

        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f"uploads/recipe/{uuid}.jpg"
        self.assertEqual(file_path, exp_path)
示例#18
0
    def test_recipe_file_name(self, mock_uuid):
        """match the uploaded file name"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid

        file_path = models.recipe_image_file_path(None, 'test.jpeg')

        exp_path = f'uploads/recipe/{uuid}.jpeg'
        self.assertEqual(file_path, exp_path)
    def test_image_filename_uuid(self, mock_uuid):
        # mock the generated uuid with test uuid
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        original_filename = 'myimage.jpg'
        file_path = models.recipe_image_file_path(None, original_filename)
        expected_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, expected_path)
示例#20
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """ test that image save with correct name and location."""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, exp_path)
 def test_recipe_file_name_uuid(self, mock_uuid):
     """Test that image is saved in the correct location"""
     uuid = 'test-uuid'
     mock_uuid.return_value = uuid
     # create a file path
     file_path = models.recipe_image_file_path(None, 'myimage.jpg')
     # expected path, string interpolation(Python3 feature)
     exp_path = f'uploads/recipe/{uuid}.jpg'
     self.assertEqual(file_path, exp_path)
示例#22
0
    def testRecipeFileNameUUID(self, mock_uuid):
        """Test tha image is saved in the correct location"""
        uuid = 'text-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = 'uploads/recipe/{}.jpg'.format(uuid)

        self.assertEqual(file_path, exp_path)
示例#23
0
    def test_recipe_file_name_decorator(self, mocked_uuid):
        """
        Test if filename store uses unique random, with patch decorator
        """
        uuid = 'test-uuid'
        mocked_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'my_image.jpg')
        expected_path = f'uploads/recipe/{uuid}.jpg'

        self.assertEqual(file_path, expected_path)
示例#24
0
    def test_recipe_file_name_uuid(self, mock_uuid: MagicMock):
        """Test file location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid

        file_path = models.recipe_image_file_path(None, 'sample.png')

        exp_path = f'uploads/recipe/{uuid}.png'

        self.assertEqual(file_path, exp_path)
示例#25
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """Test that image is saved in correct location."""
        # Every time uuid4 function is called,
        # default behaviour will be overwritten and this is returned.
        uuid = 'test_uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        expected_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, expected_path)
示例#26
0
    def test_recipe_file_name_uuid(
            self,
            mock_uuid):  #Test that image is saved in the correct location

        uuid = 'test-uuid'  #storing test unique user id in a variable
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'  #storing expected path in a variable exp_path
        self.assertEqual(file_path, exp_path)
示例#27
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        # fstring -> literal string interpolation
        # insert variables inside your string
        self.assertEqual(file_path, exp_path)
示例#28
0
    def test_recipe_filename_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        # So that means any time we call this uuid function that is triggered
        # from it in our test it will change the value, override the default
        # behaviour and return
        mock_uuid.return_value = uuid
        file_path = models.recipe_image_file_path(None, 'myimage.jpg')

        expected_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, expected_path)
示例#29
0
 def test_recipe_file_name_uuid(self, mock_uuid):
     """Test that image is saved in the correct location"""
     # Change value of uuid by adding new variable. Can be anything.
     uuid = 'test-uuid'
     # Mock the return value of uuid func by override default behavior
     mock_uuid.return_value = uuid
     # Call our new func that returns a file path
     file_path = models.recipe_image_file_path(None, 'myimage.jpg')
     # Define the expected file path so we can verify
     exp_path = f'uploads/recipe/{uuid}.jpg'
     self.assertEquals(file_path, exp_path)
示例#30
0
    def test_recipe_file_name_uuid(self, mock_uuid):
        """Test that image is saved in the correct location"""
        uuid = 'test-uuid'
        mock_uuid.return_value = uuid
        # recipe_image_file_path - function
        # first param - instance
        # second param - original file name
        file_path = models.recipe_image_file_path(None, 'image.jpg')

        exp_path = f'uploads/recipe/{uuid}.jpg'
        self.assertEqual(file_path, exp_path)