Ejemplo n.º 1
0
    def test_add_file(self, mock_request):
        """
        Test add_file
        """
        content_type = "'Content-Type': 'multipart/form-data;"
        mock_request.return_value = MockRequestResponse("")

        # small element
        self.datary.add_file(
            self.json_repo.get('workdir', {}).get('uuid'), self.element)
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(content_type in str(mock_request.call_args_list[0]))

        mock_request.reset_mock()

        # request returns None
        mock_request.return_value = None
        self.datary.add_file(
            self.json_repo.get('workdir', {}).get('uuid'), self.element)

        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(content_type in str(mock_request.call_args_list[0]))

        mock_request.reset_mock()

        # big element

        mock_request.return_value = MockRequestResponse("")

        self.datary.add_file(
            self.json_repo.get('workdir', {}).get('uuid'), self.big_element)

        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(content_type in str(mock_request.call_args_list))
Ejemplo n.º 2
0
    def test_create_repo(self, mock_describerepo, mock_request):
        """
        Test create_repo
        """
        mock_describerepo.return_value = MockRequestResponse(
            "", json=self.json_repo)
        mock_request.post.return_value = MockRequestResponse(
            "aaa", json=self.json_repo)
        repo = self.datary.create_repo('repo_name', 'category_test', amount=1)
        repo2 = self.datary.create_repo('repo_nane',
                                        'category_test',
                                        repo_uuid='123',
                                        amount=1)

        mock_request.post.side_effect = Exception('Amount not introduced')
        mock_describerepo.return_value = {}
        repo4 = self.datary.create_repo('repo_nane',
                                        'category_test',
                                        repo_uuid='123')

        self.assertEqual(repo.json().get('uuid'),
                         '47eq5s12-5el1-2hq2-2ss1-egx517b1w967')
        self.assertEqual(repo2.json().get('uuid'),
                         '47eq5s12-5el1-2hq2-2ss1-egx517b1w967')
        self.assertEqual(mock_request.post.call_count, 1)
        self.assertEqual(mock_describerepo.call_count, 3)
        self.assertEqual(repo4, {})
Ejemplo n.º 3
0
    def test_get_connection_sign_out(self, mock_request):
        """
        Test datary auth sign_out
        """

        # init datary
        self.datary = Datary(**{
            'username': self.test_username,
            'password': self.test_password,
            'token': self.test_token})

        # Fail sign out
        mock_request.return_value = MockRequestResponse(
            "Err", status_code=500)
        self.datary.get_connection_sign_out()
        self.assertEqual(self.datary.token, self.test_token)
        self.assertEqual(mock_request.call_count, 1)

        # reset mock
        mock_request.reset_mock()

        # Succes sign out
        mock_request.return_value = MockRequestResponse(
            "OK", status_code=200)

        self.assertEqual(self.datary.token, self.test_token)
        self.datary.get_connection_sign_out()
        self.assertEqual(self.datary.token, None)
        self.assertEqual(mock_request.call_count, 1)
Ejemplo n.º 4
0
    def test_get_commited_dataset_uuid(self, mock_request):
        """
        Test Datary get_commited_dataset_uuid
        """

        # no args path and basename introduced
        mock_request.return_value = MockRequestResponse("",
                                                        json=self.dataset_uuid)
        result_no_pathname = self.datary.get_commited_dataset_uuid(
            self.wdir_uuid)
        self.assertEqual(result_no_pathname, {})
        self.assertEqual(mock_request.call_count, 0)

        # good case
        result = self.datary.get_commited_dataset_uuid(self.wdir_uuid, 'path',
                                                       'basename')
        self.assertEqual(result, self.dataset_uuid)
        self.assertEqual(mock_request.call_count, 1)

        # datary request return None
        mock_request.reset_mock()
        mock_request.return_value = MockRequestResponse("", status_code=500)

        no_response_result = self.datary.get_commited_dataset_uuid(
            self.wdir_uuid, 'path', 'basename')
        self.assertEqual(no_response_result, {})
        self.assertEqual(mock_request.call_count, 1)
Ejemplo n.º 5
0
 def test(self):
     """
     Test MockRequestsResponse
     """
     test = MockRequestResponse('aaaa', path='test_path')
     self.assertEqual(test.text, 'aaaa')
     self.assertEqual(test.path(), 'test_path')
     self.assertEqual(test.encoding(), 'utf-8')
Ejemplo n.º 6
0
    def test_commit(self, mock_request):
        """
        Test Datary commit
        """

        mock_request.return_value = MockRequestResponse("a")
        self.datary.commit(self.repo_uuid, "test commit msg")

        mock_request.return_value = MockRequestResponse("ERR", status_code=500)
        self.datary.commit(self.repo_uuid, "test commit msg")

        self.assertEqual(mock_request.call_count, 2)
Ejemplo n.º 7
0
    def test_get_member_repos(self, mock_request, mock_get_members):
        """
        Test get_members
        ===============   ======  =============================================
        Parameter         Type      Description
        ===============   ======  =============================================
        mock_request      mock    Mock datary.Datary.request function
        mock_get_members  mock    Mock datary.DataryMember.get_members function
        ================  ======  =============================================
        """
        mock_get_members.return_value = {'uuid': 123, 'name': "test_member"}
        mock_request.return_value = MockRequestResponse(
            'aaa', json=[self.json_repo, self.json_repo2])

        # retrieve repos using member_uuid
        repos1 = self.datary.get_member_repos(member_uuid="123")

        self.assertEqual(repos1, [self.json_repo, self.json_repo2])
        self.assertEqual(mock_get_members.call_count, 0)
        self.assertEqual(mock_request.call_count, 1)

        mock_request.reset_mock()
        mock_get_members.reset_mock()

        # retrieve repos using member_name
        repos2 = self.datary.get_member_repos(member_name='test_member')

        self.assertEqual(repos2, [self.json_repo, self.json_repo2])
        self.assertEqual(mock_get_members.call_count, 1)
        self.assertEqual(mock_request.call_count, 1)

        mock_request.reset_mock()
        mock_get_members.reset_mock()

        # fail retrieve repos without passing args
        with self.assertRaises(Exception):
            self.datary.get_member_repos()

        self.assertEqual(mock_get_members.call_count, 0)
        self.assertEqual(mock_request.call_count, 0)

        mock_get_members.return_value = {}
        mock_request.return_value = MockRequestResponse(
            'aaa', json=[self.json_repo, self.json_repo2], status_code=500)

        # fail retrieve member
        repos3 = self.datary.get_member_repos(member_name='pepe')
        self.assertEqual(repos3, None)
        self.assertEqual(mock_get_members.call_count, 1)
        self.assertEqual(mock_request.call_count, 1)
Ejemplo n.º 8
0
    def test_get_wdir_changes(self, mock_describerepo, mock_request):
        """
        Test get_wdir_changes
        """
        mock_request.return_value = MockRequestResponse(
            "", json=self.wdir_json.get('workdir'))
        workdir = self.datary.get_wdir_changes(self.wdir_uuid)
        self.assertEqual(mock_request.call_count, 1)
        assert isinstance(workdir, dict)

        mock_describerepo.return_value = self.json_repo
        mock_request.return_value = MockRequestResponse(
            "", json=self.wdir_json.get('workdir'))
        workdir = self.datary.get_wdir_changes(repo_uuid=self.repo_uuid)
        self.assertEqual(mock_request.call_count, 2)
        assert isinstance(workdir, dict)
Ejemplo n.º 9
0
    def test_get_metadata(self, mock_request):
        """
        Test Datary datasets get_metadata
        """
        mock_request.return_value = MockRequestResponse("",
                                                        json=self.element.get(
                                                            'data',
                                                            {}).get('meta'))
        metadata = self.datary.get_metadata(self.dataset_uuid, self.repo_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(isinstance(metadata, dict))
        self.assertEqual(metadata, self.element.get('data', {}).get('meta'))

        mock_request.return_value = MockRequestResponse("", status_code=500)
        metadata2 = self.datary.get_metadata(self.dataset_uuid, self.repo_uuid)
        self.assertTrue(isinstance(metadata2, dict))
        self.assertEqual(metadata2, {})
Ejemplo n.º 10
0
    def test_describerepo(self, mock_get_member_repo, mock_request):
        """
        Test describerepo
        """
        mock_get_member_repo.return_value = self.json_repo
        mock_request.get.return_value = MockRequestResponse(
            "aaa", json=self.json_repo)

        repo = self.datary.get_describerepo(self.repo_uuid)
        self.assertEqual(mock_request.get.call_count, 1)
        assert isinstance(repo, dict)
        self.assertEqual(repo.get('name'), 'test_repo')
        self.assertEqual(mock_get_member_repo.call_count, 0)

        repo = self.datary.get_describerepo(member_uuid=self.member_uuid)
        self.assertEqual(mock_request.get.call_count, 1)
        assert isinstance(repo, dict)
        self.assertEqual(repo.get('name'), 'test_repo')
        self.assertEqual(mock_get_member_repo.call_count, 1)

        mock_request.get.return_value = MockRequestResponse(
            "", status_code=204, json=self.json_repo)
        repo2 = self.datary.get_describerepo(self.repo_uuid)
        assert isinstance(repo, dict)
        self.assertEqual(repo2.get('name'), 'test_repo')

        mock_request.get.return_value = MockRequestResponse(
            "aaa", json=[self.json_repo, self.json_repo2])
        repo3 = self.datary.get_describerepo(
            '0dc6379e-741d-11e6-8b77-86f30ca893d3')
        assert isinstance(repo, dict)
        self.assertEqual(repo3.get('name'), 'test_repo2')

        repo4 = self.datary.get_describerepo(repo_name='test_repo2')
        assert isinstance(repo, dict)
        self.assertEqual(repo4.get('name'), 'test_repo2')

        mock_request.get.return_value = MockRequestResponse("a", json=[])
        repo5 = self.datary.get_describerepo(repo_name='test_repo2')
        self.assertEqual(repo5, {})

        # check fail requests returns None
        mock_request.get.return_value = MockRequestResponse("Break test",
                                                            status_code=500)
        repo6 = self.datary.get_describerepo(repo_name='test_repo2')
        self.assertEqual(repo6, {})
Ejemplo n.º 11
0
 def test_get_wdir_filetree(self, mock_request):
     """
     Test get_wdir_filetree
     """
     mock_request.return_value = MockRequestResponse(
         "", json=self.wdir_json.get('changes'))
     changes = self.datary.get_wdir_filetree(self.repo_uuid)
     self.assertEqual(mock_request.call_count, 1)
     assert isinstance(changes, dict)
Ejemplo n.º 12
0
    def test_override_file(self, mock_modify_requests):
        """
        Test datary operation modify override_file
        """

        mock_modify_requests.return_value = MockRequestResponse("")
        self.datary.override_file(
            self.json_repo.get('workdir', {}).get('uuid'), self.element)
        self.assertEqual(mock_modify_requests.call_count, 1)
Ejemplo n.º 13
0
 def test_get_commit_filetree(self, mock_request):
     """
     Test get_commit_filetree
     """
     mock_request.return_value = MockRequestResponse(
         "", json=self.wdir_json.get('workdir'))
     workdir = self.datary.get_commit_filetree(
         self.repo_uuid, self.commit_sha1)
     self.assertEqual(mock_request.call_count, 1)
     assert isinstance(workdir, dict)
Ejemplo n.º 14
0
    def test_delete_member_session(self, mock_request):
        # Fail sign out
        mock_request.return_value = MockRequestResponse(
            "Err", status_code=500)
        self.datary.delete_member_session()
        self.assertEqual(self.datary.token, self.test_token)
        self.assertEqual(mock_request.call_count, 1)

        # reset mock
        mock_request.reset_mock()

        # Succes sign out
        mock_request.return_value = MockRequestResponse(
            "OK", status_code=200)

        self.assertEqual(self.datary.token, self.test_token)
        self.datary.delete_member_session()
        self.assertEqual(self.datary.token, None)
        self.assertEqual(mock_request.call_count, 1)
Ejemplo n.º 15
0
 def test_delete_file(self, mock_request):
     """
     Test operation remove delete_file
     """
     mock_request.return_value = MockRequestResponse("")
     self.datary.delete_file(
         self.json_repo.get('workdir', {}).get('uuid'), self.element)
     mock_request.return_value = None
     self.datary.delete_file(
         self.json_repo.get('workdir', {}).get('uuid'), self.element)
     self.assertEqual(mock_request.call_count, 2)
Ejemplo n.º 16
0
    def test_deleterepo(self, mock_request):
        """
        Test deleterepo
        """
        mock_request.delete.return_value = MockRequestResponse(
            "Repo {} deleted".format('123'))
        result = self.datary.delete_repo(repo_uuid='123')
        self.assertEqual(result, 'Repo 123 deleted')

        with self.assertRaises(Exception):
            self.datary.delete_repo()
Ejemplo n.º 17
0
 def test_add_dir(self, mock_request):
     """
     Test add_dir
     """
     mock_request.return_value = MockRequestResponse("")
     self.datary.add_dir(
         self.json_repo.get('workdir', {}).get('uuid'), 'path', 'dirname')
     mock_request.return_value = None
     self.datary.add_dir(
         self.json_repo.get('workdir', {}).get('uuid'), 'path', 'dirname')
     self.assertEqual(mock_request.call_count, 2)
Ejemplo n.º 18
0
    def test_get_connection_sign_in(self, mock_request):
        """
        Test datary auth get_user_token
        """

        # init datary
        self.datary = Datary(**{
            'username': self.test_username,
            'password': self.test_password,
            'token': self.test_token})

        # Assert init class data & token introduced by args
        self.assertEqual(self.datary.username, self.test_username)
        self.assertEqual(self.datary.password, self.test_password)
        self.assertEqual(self.datary.token, self.test_token)
        self.assertEqual(mock_request.call_count, 0)

        # Assert get token in __init__
        mock_request.return_value = MockRequestResponse(
            "", headers={'x-set-token': self.test_token})
        self.datary = Datary(**{'username': '******', 'password': '******'})
        self.assertEqual(mock_request.call_count, 1)

        # Assert get token by the method without args.
        mock_request.return_value = MockRequestResponse(
            "", headers={'x-set-token': self.test_token})
        token1 = self.datary.get_connection_sign_in()
        self.assertEqual(token1, self.test_token)

        # Assert get token by method     with args.
        mock_request.return_value = MockRequestResponse(
            "", headers={'x-set-token': '456'})
        token2 = self.datary.get_connection_sign_in('maria', 'pass2')
        self.assertEqual(token2, '456')

        mock_request.return_value = MockRequestResponse("", headers={})
        token3 = self.datary.get_connection_sign_in('maria', 'pass2')
        self.assertEqual(token3, '')

        self.assertEqual(mock_request.call_count, 4)
Ejemplo n.º 19
0
    def test_modify_request(self, mock_request):
        """
        Test datary operation modify modify_request
        """
        mock_request.return_value = MockRequestResponse("")
        self.datary.modify_request(
            self.json_repo.get('workdir', {}).get('uuid'), self.element)

        mock_request.return_value = None

        self.datary.modify_request(
            self.json_repo.get('workdir', {}).get('uuid'), self.big_element)
        self.assertEqual(mock_request.call_count, 2)
Ejemplo n.º 20
0
    def testclear_index(self, mock_request):
        """
        Test operation remove clear_index
        """
        mock_request.return_value = MockRequestResponse("", json={})
        original = self.datary.clear_index(self.wdir_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertEqual(original, True)

        mock_request.reset_mock()
        mock_request.return_value = None
        original2 = self.datary.clear_index(self.wdir_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertEqual(original2, False)
Ejemplo n.º 21
0
    def test_delete_inode(self, mock_request):
        """
        Test operation remove delete_inode
        """
        mock_request.return_value = MockRequestResponse("")
        self.datary.delete_inode(
            self.json_repo.get('workdir', {}).get('uuid'), self.inode)
        mock_request.return_value = None
        self.datary.delete_inode(
            self.json_repo.get('workdir', {}).get('uuid'), self.inode)
        self.assertEqual(mock_request.call_count, 2)

        mock_request.side_effect = Exception('Test Err exception')
        with self.assertRaises(Exception):
            self.datary.delete_inode(
                self.json_repo.get('workdir', {}).get('uuid'), self.inode)
Ejemplo n.º 22
0
    def test_properties(self, mock_request):
        """
        Test Datary auth getter/setter properties
        """

        mock_request.return_value = MockRequestResponse(
            "", headers={'x-set-token': self.test_token})
        self.datary = Datary(**{
            'username': self.test_username,
            'password': self.test_password})
        self.assertEqual(mock_request.call_count, 1)

        self.assertEqual(self.datary.username, self.test_username)
        self.assertEqual(self.datary.password, self.test_password)
        self.assertEqual(self.datary.token, self.test_token)
        self.assertEqual(self.datary.commit_limit, self.test_commit_limit)
        self.assertIn(
            self.datary.token, self.datary.headers.get('Authorization'))

        self.datary.username = self.test_username2
        self.datary.password = self.test_password2
        self.datary.token = self.test_token2
        self.datary.commit_limit = self.test_commit_limit2

        self.assertEqual(self.datary.username, self.test_username2)
        self.assertEqual(self.datary.password, self.test_password2)
        self.assertEqual(self.datary.token, self.test_token2)
        self.assertEqual(self.datary.commit_limit, self.test_commit_limit2)
        self.assertIn(
            self.datary.token, self.datary.headers.get('Authorization'))

        # no username sig-in
        self.datary.username = None
        self.datary.token = None
        self.datary.sign_in()
        self.assertEqual(self.datary.token, None)

        # no password sig-in
        self.datary.username = '******'
        self.datary.password = None
        self.datary.token = None
        self.datary.sign_in()
        self.assertEqual(self.datary.token, None)
Ejemplo n.º 23
0
    def test_rename_file(self, mock_request):
        """
        Test add_dir
        """
        mock_request.return_value = MockRequestResponse("")
        self.datary.rename_file(
            self.json_repo.get('workdir', {}).get('uuid'),
            {'path': 'test_path/path', 'basename': 'test_basename'},
            {'path': 'test_path/new_path', 'basename': 'test_new_basename'},
            )
        self.assertEqual(mock_request.call_count, 1)

        mock_request.reset_mock()

        mock_request.return_value = None
        self.datary.rename_file(
            self.json_repo.get('workdir', {}).get('uuid'),
            {'path': 'test_path/path', 'basename': 'test_basename'},
            {'path': 'test_path/new_path', 'basename': 'test_new_basename'},
            )
        self.assertEqual(mock_request.call_count, 1)
Ejemplo n.º 24
0
    def test_get_members(self, mock_request):
        """
        Test get_members
        =============   =============   ===================================
        Parameter       Type            Description
        =============   =============   ===================================
        mock_request    mock            Mock datary.Datary.request function
        =============   =============   ===================================
        """

        mock_request.return_value = MockRequestResponse("aaa",
                                                        json=self.members)
        member = self.datary.get_members(member_name='username1')
        self.assertEqual(member, self.members[0])

        member2 = self.datary.get_members(
            member_uuid=self.members[1].get('uuid'))
        self.assertEqual(member2, self.members[1])

        members_fail = self.datary.get_members(member_name='username3')
        self.assertEqual(members_fail, {})

        members_limit = self.datary.get_members()
        assert isinstance(members_limit, list)
Ejemplo n.º 25
0
    def test_get_original(self, mock_request):
        """
        Test Datary datasets get_original
        """

        mock_request.return_value = MockRequestResponse("", json=self.original)
        original = self.datary.get_original(self.dataset_uuid, self.repo_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(isinstance(original, dict))
        self.assertEqual(original, self.original)
        mock_request.reset_mock()

        # not dataset_uuid, introduced
        original2 = self.datary.get_original(self.dataset_uuid, self.repo_uuid,
                                             self.wdir_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(isinstance(original2, dict))
        self.assertEqual(original2, self.original)
        mock_request.reset_mock()

        # not dataset_uuid, introduced
        original3 = self.datary.get_original(self.dataset_uuid,
                                             wdir_uuid=self.wdir_uuid)
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(isinstance(original3, dict))
        self.assertEqual(original3, self.original)
        mock_request.reset_mock()

        mock_request.side_effect = iter([
            MockRequestResponse("", status_code=500),
            MockRequestResponse("", json=self.original)
        ])

        original4 = self.datary.get_original(self.dataset_uuid, self.repo_uuid)
        self.assertEqual(mock_request.call_count, 2)
        self.assertTrue(isinstance(original4, dict))
        self.assertEqual(original4, self.original)
        mock_request.reset_mock()

        mock_request.side_effect = iter([
            MockRequestResponse("", status_code=500),
            MockRequestResponse("", status_code=500)
        ])

        original4b = self.datary.get_original(self.dataset_uuid,
                                              self.repo_uuid)
        self.assertEqual(mock_request.call_count, 2)
        self.assertTrue(isinstance(original4b, dict))
        self.assertEqual(original4b, {})
        mock_request.reset_mock()

        # not dataset_uuid, introduced
        original5 = self.datary.get_original(
            MockRequestResponse("", status_code=500))

        self.assertEqual(mock_request.call_count, 0)
        self.assertTrue(isinstance(original5, dict))
        self.assertEqual(original5, {})
        mock_request.reset_mock()

        # scope
        mock_request.side_effect = iter([
            MockRequestResponse("", json=self.original),
            MockRequestResponse("", json=self.original)
        ])
        original6 = self.datary.get_original(self.dataset_uuid,
                                             self.repo_uuid,
                                             scope='repo')
        self.assertEqual(mock_request.call_count, 1)
        self.assertTrue(isinstance(original6, dict))
        self.assertEqual(original6, self.original)
Ejemplo n.º 26
0
    def test_request(self, mock_time, mock_requests):
        """
        Test get_request
        =============   =============   =======================================
        Parameter       Type            Description
        =============   =============   =======================================
        mock_request    mock            Mock datary.requests.requests.request
                                        function
        =============   =============   =======================================
        """

        mock_requests.get.return_value = MockRequestResponse(
            "ok", headers={'x-set-token': self.test_token})
        mock_requests.post.return_value = MockRequestResponse(
            "ok", headers={'x-set-token': self.test_token})
        mock_requests.put.return_value = MockRequestResponse(
            "ok", headers={'x-set-token': self.test_token})
        mock_requests.delete.return_value = MockRequestResponse(
            "ok", headers={'x-set-token': self.test_token})

        # test GET
        result1 = self.datary.request(self.url, 'GET')
        self.assertEqual(result1.text, 'ok')

        # test POST
        result2 = self.datary.request(self.url, 'POST')
        self.assertEqual(result2.text, 'ok')

        # test PUT
        result3 = self.datary.request(self.url, 'PUT')
        self.assertEqual(result3.text, 'ok')

        # test DELETED
        result4 = self.datary.request(self.url, 'DELETE')
        self.assertEqual(result4.text, 'ok')

        # test UNKNOWK http method
        with self.assertRaises(Exception):
            self.datary.request(self.url, 'UNKWOWN')

        # test status code wrong
        mock_requests.get.return_value = MockRequestResponse("err",
                                                             status_code=500)
        result5 = self.datary.request(self.url, 'GET')
        self.assertEqual(result5, None)

        # test status code 429
        responses_429_test = [
            MockRequestResponse(
                "Request limit exceeded, must wait for XX seconds",
                status_code=429),
            MockRequestResponse(
                "Request limit exceeded, must wait for XX seconds",
                status_code=429),
            MockRequestResponse(
                "Request limit exceeded, must wait for XX seconds",
                status_code=429),
            MockRequestResponse("Everything OK", status_code=200)
        ]

        mock_requests.get.side_effect = iter(responses_429_test)

        result7 = self.datary.request(self.url, 'GET')
        self.assertEqual(result7, None)

        # upgrade tries limit
        self.datary.tries_limit = 4
        mock_requests.get.side_effect = iter(responses_429_test)

        result8 = self.datary.request(self.url, 'GET')
        self.assertEqual(result8.text, 'Everything OK')

        self.assertEqual(mock_time.sleep.call_count, 3 + 3)

        mock_requests.get.side_effect = requests.RequestException('err')
        result6 = self.datary.request(self.url, 'GET')
        self.assertEqual(result6, None)

        self.assertEqual(mock_requests.get.call_count, 10)
        self.assertEqual(mock_requests.post.call_count, 1)
        self.assertEqual(mock_requests.put.call_count, 1)
        self.assertEqual(mock_requests.delete.call_count, 1)