コード例 #1
0
 def test_campaigns_delete_with_invalid_ids(self, token_first):
     """
     User auth token is valid, data is in valid format but ids are not valid
     We are expecting 400 from this request
     """
     data = {'ids': [0, 'a', 'b']}
     delete_campaigns(data, token_first, expected_status=(codes.BAD_REQUEST,))
コード例 #2
0
 def test_campaigns_delete_with_campaign_ids_in_non_list_form(self, token_first, campaign_in_db):
     """
     User auth token is valid, but invalid data provided(other than list).
     ids must be in list format
     It should get bad request error.
     """
     data = {'ids': campaign_in_db['id']}
     delete_campaigns(data, token_first, expected_status=(codes.BAD_REQUEST,))
コード例 #3
0
 def test_campaigns_delete_with_invalid_token(self, campaign_in_db):
     """
     User auth token is invalid, it should get Unauthorized.
     """
     data = {
         'ids': [campaign_in_db['id']]
     }
     delete_campaigns(data, 'invalid_token', expected_status=(codes.UNAUTHORIZED,))
コード例 #4
0
 def test_campaigns_delete_with_unauthorized_id(self, token_second, campaign_in_db):
     """
     User auth token is valid, data type is valid and ids are of those campaigns that
     belong to some other user. It should get unauthorized error.
     :param token_second: auth token for user_second
     :param campaign_in_db: campaign created in fixture
     """
     data = {'ids': [campaign_in_db['id']]}
     delete_campaigns(data, token_second, expected_status=(codes.FORBIDDEN,))
コード例 #5
0
 def test_campaigns_delete_with_existing_and_non_existing_ids(self, token_first, campaign_in_db):
     """
     Test with one existing, one invalid id and one non existing ids of push campaign.
     It should get 404 status code.
     :param token_first: auth token
     :param campaign_in_db: campaign created by user_first
     """
     non_existing_id = sys.maxint
     data = {'ids': [campaign_in_db['id'], non_existing_id]}
     delete_campaigns(data, token_first, expected_status=(codes.NOT_FOUND,))
コード例 #6
0
 def test_campaigns_delete_with_authorized_ids(self, token_first, campaign_in_db):
     """
     User auth token is valid, data type is valid and ids are valid
     (campaign corresponds to user). Response should be OK.
     :param token_first: auth token
     :param campaign_in_db: campaign created in fixture
     """
     data = {'ids': [campaign_in_db['id']]}
     delete_campaigns(data, token_first, expected_status=(codes.OK,))
     assert_activity(Activity.MessageIds.CAMPAIGN_DELETE, campaign_in_db['id'], 'push_campaign', token_first)
コード例 #7
0
    def test_campaigns_delete_with_other_user_with_same_domain(self, token_same_domain, campaign_in_db):
        """
        User auth token is valid, data type is valid and ids are of those campaigns that
        belong to some other user. It should get unauthorized error.
        :param token_same_domain: auth token
        :param campaign_in_db: campaign created by user_first
        """
        data = {'ids': [campaign_in_db['id']]}
        delete_campaigns(data, token_same_domain, expected_status=(codes.OK,))

        # Check campaign creation activity
        assert_activity(Activity.MessageIds.CAMPAIGN_DELETE, campaign_in_db['id'], 'push_campaign', token_same_domain)
コード例 #8
0
 def test_campaigns_delete_with_deleted_record(self, token_first, campaign_in_db):
     """
     We first delete a campaign, and again try to delete it. It should get
     ResourceNotFound error.
     :param token_first: auth token
     :param campaign_in_db: campaign created by user_first
     """
     campaign_id = campaign_in_db['id']
     delete_campaign(campaign_id, token_first)
     data = {
         'ids': [campaign_in_db['id']]
     }
     delete_campaigns(data, token_first, expected_status=(codes.NOT_FOUND,))
コード例 #9
0
 def test_campaigns_delete_authorized_and_unauthorized_ids(self, token_first, campaign_in_db,
                                                           campaign_in_db_second):
     """
     Test with one authorized and one unauthorized push campaign. It should get 403
     status code.
     :param token_first: auth token
     :param campaign_in_db: campaign created by user_first
     :param campaign_in_db_second: campaign created by user_second
     """
     response = send_request('delete', URL, token_first, data={'ids': [campaign_in_db['id'],
                                                                       campaign_in_db_second['id']]})
     assert response.status_code == codes.FORBIDDEN
     data = {'ids': [campaign_in_db['id'], campaign_in_db_second['id']]}
     delete_campaigns(data, token_first, expected_status=(codes.FORBIDDEN,))
コード例 #10
0
 def tear_down():
     data = {'ids': ids}
     delete_campaigns(data,
                      token_first,
                      expected_status=(codes.OK, codes.MULTI_STATUS))