示例#1
0
    def setUp(self):
        self.app = app
        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()
        db.create_all()

        # Creating the 1st user. This user will issue a request
        user = User(username=self.default_username)
        user.set_password_hash(self.default_password)
        db.session.add(user)
        db.session.commit()
        self.client = TestClient(self.app, user.generate_auth_token(), '')

        # Create a request for 1st user
        request_data = {
            'meal_type': 'Vietnamese',
            'meal_time': 'Dinner',
            'location_string': 'San Francisco'
        }
        rv, json = self.client.post(API_VERSION + '/requests/',
                                    data=request_data)
        self.request_location = rv.headers['Location']

        # Create the 2nd user. This user will make proposal for the request by
        # 1st user
        user_2 = User(username='******')
        user_2.set_password_hash('123456')
        db.session.add(user_2)
        db.session.commit()
        self.client = TestClient(self.app, user_2.generate_auth_token(), '')
示例#2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.start_date = self.get_properties().get("start_date")
     self.client = TestClient({
         **self.get_properties(),
         **self.get_credentials(),
     })
示例#3
0
 def set_environment(self, env):
     """
     Change the Square App Environmnet.
     Requires re-instatiating TestClient and setting env var.
     """
     os.environ['TAP_SQUARE_ENVIRONMENT'] = env
     self.client = TestClient(env=env)
     self.SQUARE_ENVIRONMENT = env
示例#4
0
 def setUp(self):
     self.app = app
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()
     db.create_all()
     u = User(username=self.default_username)
     u.set_password(self.default_password)
     db.session.add(u)
     db.session.commit()
     self.client = TestClient(self.app, u.generate_auth_token(), '')
示例#5
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        u = User(username=self.default_username,
                 password=self.default_password)
        db.session.add(u)
        db.session.commit()

        self.client = TestClient(self.app, u.generate_auth_token(), '')
示例#6
0
 def tearDownClass(cls):
     cls.set_environment(cls, cls.SANDBOX)
     cleanup = {'categories': 10000}
     client = TestClient(env=os.environ['TAP_SQUARE_ENVIRONMENT'])
     for stream, limit in cleanup.items():
         print("Checking if cleanup is required.")
         all_records = client.get_all(stream, start_date=cls.STATIC_START_DATE)
         all_ids = [rec.get('id') for rec in all_records if not rec.get('is_deleted')]
         if len(all_ids) > limit / 2:
             chunk = int(len(all_ids) - (limit / 2))
             print("Cleaning up {} excess records".format(chunk))
             client.delete_catalog(all_ids[:chunk])
示例#7
0
    def setUp(self):
        self.app = create_app('testing')

        # add an additional route used only in tests
        @self.app.route('/foo')
        @async
        def foo():
            1 / 0

        @self.app.route('/test-long')
        @async
        def long_task():
            sleep(10)
            return jsonify({}), 200

        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        u = User(username=self.default_username,
                 password=self.default_password)

        self.client = TestClient(self.app, u.generate_auth_token(),'')
示例#8
0
def run_deepweb_test():
    t = TestClient(service_host="http://0.0.0.0:8080", auth=('admin', 'admin'))

    test_files_dict = {
        "Hidden Service lists and search engines": "test_link_sites.json",
        "Marketplace Financial": "test_finance.json",
        "Marketplace Commercial Services": "test_commercial_services.json",
        "Blogs and radios": "test_blogs.json",
        "Politics": "test_politics.json"
    }

    for tests_name, tests_file in test_files_dict.items():
        print(
            "======================================================================"
        )
        print("Website group: %s from file %s" % (tests_name, tests_file))
        print(
            "======================================================================"
        )
        with open(tests_file) as f:
            tests_json = json.load(f)
            # Get archives for each individual page
            for web_name, url in tests_json.items():
                print("Website: %s, URL: %s" % (web_name, url))
                data = {
                    'urls': [url],
                    'name': "DeepWebTest-{}".format(t.test_number),
                    'headers': {},
                    'forceTor': True,
                }

                timing_start = time.time()
                t.get_archive(data=data)
                timing_end = time.time()
                print("  archiving request time: %s" %
                      (timing_end - timing_start))
 def setUpClass(cls):
     print("\n\nTEST SETUP\n")
     cls.client = TestClient()
示例#10
0
"""
This is used for testing basic functionality of the test client.
To run change the desired flags below and use the following command from the tap-tester repo:
  'python ../tap-square/tests/client_tester.py'
"""
from datetime import datetime

from test_client import TestClient

##########################################################################
# Testing the TestCLient
##########################################################################
if __name__ == "__main__":
    client = TestClient(env='sandbox')
    # START_DATE = '2020-06-24T00:00:00Z'
    START_DATE = datetime.strftime(datetime.utcnow(), '%Y-%m-%dT00:00:00Z')

    # CHANGE FLAGS HERE TO TEST SPECIFIC FUNCTION TYPES
    test_creates = True
    test_updates = False  # To test updates, must also test creates
    test_gets = False
    test_deletes = True  # To test deletes, must also test creates

    # CHANGE FLAG TO PRINT ALL OBJECTS THAT FUNCTIONS INTERACT WITH
    print_objects = True

    objects_to_test = [  # CHANGE TO TEST DESIRED STREAMS
        # 'modifier_lists', # GET - DONE | CREATE -  | UPDATE -  | DELETE -
        # 'inventories', # GET - DONE | CREATE - DONE | UPDATE - DONE | DELETE -
        # 'items',  # GET - DONE | CREATE - DONE | UPDATE - DONE | DELETE -
        'categories',  # GET - DONE | CREATE - DONE | UPDATE - DONE | DELETE - DONE
 def setUpClass(cls):
     cls.tc = TestClient()
示例#12
0
"""
This is used for testing basic functionality of the test client.
To run change the desired flags below and use the following command from the tap-tester repo:
  'python ../tap-adroll/tests/client_tester.py'
"""
from test_client import TestClient

##########################################################################
# Testing the TestCLient
##########################################################################
if __name__ == "__main__":
    client = TestClient()

    # CHANGE FLAGS HERE TO TEST SPECIFIC FUNCTION TYPES
    test_creates = False
    test_updates = True
    test_gets = False
    test_deletes = False

    # CHANGE FLAG TO PRINT ALL OBJECTS THAT FUNCTIONS INTERACT WITH
    print_objects = True

    objects_to_test = [  # CHANGE TO TEST DESIRED STREAMS 
    ]
    # 'ads', # GET - DONE | CREATE - DONE | UPDATE - DONE
    # 'ad_groups', # GET - DONE | CREATE - DONE | UPDATE - DONE
    # 'segments', # GET - DONE | CREATE - DONE | UPDATE - DONE
    # 'campaigns', # GET - DONE | CREATE - DONE | UPDATES - DONE
    # 'advertisables', # GET - DONE | CREATE NA (DONT DO THIS ONE)
    # 'ad_reports', GET - DONE | CREATE - N/A
示例#13
0
 def __init__(self, num_length):
     self.test_client = TestClient()
     #self.data_array = np.zeros(num_length)
     #self.data_array = np.zeros(num_length)
     self.data_array = [None] * num_length
     self.num_length = num_length