Example #1
0
  def test_understanding(self):
    """
    Tests that SMS messages can be properly understood
    """
    from apps.admin.models.account import Account
    account = Account(password="******")
    account.save()
    from apps.seller.models.seller import Seller
    seller = Seller(account=account)
    seller.save()
    from apps.seller.models.product import Product
    product = Product(seller=seller)
    product.save()

    tracking_test_cases = ["CP123456789012MA", "RR123456MA"]#, "CP 12345678 MA"
    for tracking_num in tracking_test_cases:
      message_tests = [
        "%d %s" % (product.id, tracking_num),
        "  %d    %s   " % (product.id, tracking_num),
        "%d something %s random" % (product.id, tracking_num),
        #"%s %d" % (tracking_num, product.id),
      ]
      for message in message_tests:
        result = sms.understandMessage(message)
        self.assertIsNot(result, False, "SMS message \"%s\" not understood" % message)
        (found_product_id, actions) = result
        self.assertEqual(product.id, int(found_product_id), "SMS product id not identified")
        self.assertEqual(actions['tracking_number'], tracking_num, "SMS tracking \"%s\" not found in \"%s\"" % (tracking_num, message))
Example #2
0
def create(account):
  try:
    from apps.seller.models.seller import Seller
    seller_account = Seller(account_id=account.id)
    seller_account.save()
    return True
  except Exception as e:
    ExceptionHandler(e, "in account.create")
    return False