def create_random_product_scans(latitude_center, longitude_center, radius, count): store = stores.Store.create_store("test_store_%f" % random.random()) stores.StoreInstance.create_store_instance("test_address_%f" % random.random(), latitude_center, longitude_center, store) product = product_steps.create_random_product() for i in range(1, count): latitude = latitude_center + (random.random() * util.meters_to_latitude(radius)) longitude = longitude_center + (random.random() * util.meters_to_longitude(radius, latitude)) api_handler.create_product_scan(world.mobile_number, world.password, world.client_uid, product.barcode, products.BARCODE_TYPES.EAN13, str(latitude), str(longitude))
def i_cannot_contribute_to_the_crowd_database_on_an_existing_product_with_non_existant_user(step): world.mobile_number = "I_DONT_EXIST" world.client_uid = "UID_THAT_DOESNT_EXIST" product = create_random_product() try: api_handler.create_product_scan(world.mobile_number, world.password, world.client_uid, product.barcode, products.BARCODE_TYPES.EAN13, "1.0", "2.0") raise BaseException("Was able to contribute even though I don't exist!") except api_handler.WebserviceException: pass
def then_i_cannot_contribute_to_the_crowd_database_on_an_existing_product(step): product = create_random_product() if world.client_uid is None: world.client_uid = clients.Client.objects.get_by_password(world.mobile_number, world.password) try: api_handler.create_product_scan(world.mobile_number, world.password, world.client_uid, product.barcode, products.BARCODE_TYPES.EAN13, "1.0", "2.0") raise BaseException("Was able to contribute even though not verified") except api_handler.WebserviceException: pass
def and_i_can_contribute_to_crowd_database_on_an_existing_product(step): product = create_random_product() api_handler.create_product_scan(world.mobile_number, world.password, world.client_uid, product.barcode, products.BARCODE_TYPES.EAN13, "1.0", "2.0")