Esempio n. 1
0
def main():
    from redisu.utils.clean import clean_keys
    global redis
    redis = Redis(host=os.environ.get("REDIS_HOST", "localhost"),
                  port=os.environ.get("REDIS_PORT", 6379),
                  password=os.environ.get("REDIS_PASSWORD", None),
                  db=0,
                  decode_responses=True)

    clean_keys(redis, "hits")
    redis.set("hits:homepage", 2000)
    redis.set("hits:loginpage", 75)

    # Register our script with the Redis Python client and
    # return a callable object for invoking our script.
    stats = redis.register_script(stats_script)

    # Invoke our "sum" script.
    # This calls SCRIPT LOAD and then stores
    # the SHA1 digest of the script for future use.
    total = stats(["hits:homepage", "hits:loginpage"], ["sum"])
    assert (total == 2075)

    # Two more tests.
    max = stats(["hits:homepage", "hits:loginpage"], ["max"])
    assert (max == 2000)
Esempio n. 2
0
def main():
    """ Main, used to call test cases for this use case"""
    from redisu.utils.clean import clean_keys

    global redis
    redis = StrictRedis(host=os.environ.get("REDIS_HOST", "localhost"),
                        port=os.environ.get("REDIS_PORT", 6379),
                        db=0)
    clean_keys(redis)

    # Performs the tests
    test_pub_sub()
Esempio n. 3
0
def main():
    """ Main, used to call test cases for this use case"""
    from redisu.utils.clean import clean_keys

    global redis
    redis = StrictRedis(host=os.environ.get("REDIS_HOST", "localhost"),
                        port=os.environ.get("REDIS_PORT", 6379),
                        db=0)
    clean_keys(redis)
    # Perform the test cases
    test_create_seat_map()
    test_find_seats()
    test_reserved_seats()
Esempio n. 4
0
def main():
  """ Main, used to call test cases for this use case"""
  from redisu.utils.clean import clean_keys

  global redis
  redis = Redis(host=os.environ.get("REDIS_HOST", "localhost"),
                port=os.environ.get("REDIS_PORT", 6379),
                password=os.environ.get("REDIS_PASSWORD", None),
                db=0, decode_responses=True)
  clean_keys(redis)

  # Performs the tests
  test_pub_sub()
Esempio n. 5
0
def main():
    """ Main, used to call test cases for this use case"""
    from redisu.utils.clean import clean_keys

    global redis
    redis = StrictRedis(host=os.environ.get("REDIS_HOST", "localhost"),
                        port=os.environ.get("REDIS_PORT", 6379),
                        db=0)
    clean_keys(redis)
    create_customers(customers)
    # Performs the tests
    test_check_and_purchase()
    test_reserve()
    test_expired_res()
Esempio n. 6
0
def main():
  """ Main, used to call test cases for this use case"""
  from redisu.utils.clean import clean_keys

  global redis
  redis = StrictRedis(host=os.environ.get("REDIS_HOST", "localhost"),
                      port=os.environ.get("REDIS_PORT", 6379),
                      db=0)
  clean_keys(redis)

  # Perform the tests
  test_object_inspection()
  test_faceted_search()
  test_hashed_faceting()
Esempio n. 7
0
def main():
    """ Main, used to call test cases for this use case"""
    from redisu.utils.clean import clean_keys

    global redis
    redis = Redis(host=os.environ.get("REDIS_HOST", "localhost"),
                  port=os.environ.get("REDIS_PORT", 6379),
                  db=0,
                  decode_responses=True)

    clean_keys(redis)
    # Performs the tests
    test_venue_search()
    test_event_search()
    test_transit_search()
Esempio n. 8
0
    def test_reserve_tickets(self):
        # Get the customer
        customer = self.redis.hgetall(self.customer_key)

        # Get a reference to our Lua script
        request_tickets = self.redis.register_script(request_ticket_hold_v1_script)

        # Request 10 tickets and hold for 30 seconds
        result = request_tickets([self.event_key], [customer['id'], 10, 30])
        assert(result == 1)

        # Request 500 tickets and hold for 30 seconds
        result = request_tickets([self.event_key], [customer['id'], 500, 30])
        assert(result == 0)

        # Clear all hold keys
        clean_keys(self.redis, "hold")
Esempio n. 9
0
    def test_sum_reserved_tickets(self):
        customer_ids = [c['id'] for c in CUSTOMERS]
        # Number of tickets to reserve per customer
        reserve_count = 13

        # Get a reference to our reservation and summation scripts
        request_tickets = self.redis.register_script(request_ticket_hold_v1_script)
        sum = self.redis.register_script(held_ticket_count_script)

        # Request several tickets and hold them for 30 seconds
        for customer_id in customer_ids:
            result = request_tickets([self.event_key], [customer_id, reserve_count, 30])
            assert(result == 1)

        assert(sum([self.event_key]) == reserve_count * len(customer_ids))

        # Clear all hold keys
        clean_keys(self.redis, "hold")