Beispiel #1
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])
Beispiel #2
0
                if test_updates:  # Need to reference specific attr from an obj to update
                    print("Testing UPDATE: {}".format(obj))
                    # import pdb; pdb.set_trace() # UNCOMMENT TO RUN 'INTERACTIVELY'
                    obj_id = created_obj[0].get('id')
                    version = created_obj[0].get('version')
                    updated_obj = client.update(stream=obj,
                                                obj_id=obj_id,
                                                version=version,
                                                obj=created_obj[0],
                                                start_date=START_DATE)
                    if updated_obj:
                        print("SUCCESS")
                        if print_objects:
                            print("{}\n".format(updated_obj))
                        continue
                    print("FAILED")

                if test_deletes:  # Need to reference id from an obj to delete
                    print("Testing UPDATE: {}".format(obj))
                    # import pdb; pdb.set_trace() # UNCOMMENT TO RUN 'INTERACTIVELY'
                    obj_ids = [created_obj[0].get('id')]
                    version = created_obj[0].get('version')
                    deleted_obj = client.delete_catalog(ids_to_delete=obj_ids)
                    if deleted_obj:
                        print("SUCCESS")
                        if print_objects:
                            print("{}\n".format(deleted_obj))
                        continue
                    print("FAILED")