Exemple #1
0
 def test_get_channel_from_customer(self):
     """
         Checks if a customer have a channel or not
     """
     customer = Customer.get_customer(self.customer_name, self.customer_pass)
     if customer is Customer.WRONG_USERNAME_OR_PASSWORD:
         self.fail('Couldnt get the customer')        
     self.assertEqual(False, Customer.can_send_to_channel(customer, channel='this_channel_doesnt_exists'))
Exemple #2
0
 def test_check_id_error (self):
     """
         If the Id is valid and pepito is the owner of the message and there is an error.
     """
     customer = Customer.get_customer ('pepito', 'password')
     (status, status_msg) = SMSHistory.check_id (customer, 'testMessage2')[0]
     self.assertEqual ((status, status_msg), (True, 'A critical error'))
Exemple #3
0
 def test_check_id_not_error (self):
     """
         If the Id is valid, pepito is the owner of the message and there isn't an error
     """
     customer = Customer.get_customer ('pepito', 'password')
     (status, status_msg) = SMSHistory.check_id (customer, 'testMessage1')[0]
     self.assertEqual ((status, status_msg), (False, ''))
Exemple #4
0
 def test_check_id_invalid_id (self):
     """
         If the Id is invalid
     """
     customer = Customer.get_customer ('pepito', 'password')
     (status, status_msg) = SMSHistory.check_id (customer, '{--Invalid_ID--}')[0]
     self.assertEqual ((status, status_msg), (True, 'badid'))
Exemple #5
0
 def test_check_customer_and_credit_insufficient_credit_no_purchase (self):
     #ret = Customer.check_customer_and_credit ('pepito', 'password', 'AccessNoPurchase', 2)
     try:
         ret = Customer.check_customer_and_credit (self.customer_name, self.customer_pass, self.account_name, 10000)
     except OutOfCredit:
         self.assertEqual
     else:
         self.fail('')        
Exemple #6
0
 def test_check_customer_and_credit_insufficient_credit_purchas (self):
     #ret = Customer.check_customer_and_credit ('pepito', 'password', 'AccessWithPurchase', 10000)
     try:
         ret = Customer.check_customer_and_credit (self.customer_name, self.customer_pass, self.account_name, 10000)
     except OutOfCredit:
         self.assertEqual
     else:
     #self.assertEqual (ret, Purchase.INSUFFICIENT_CREDIT)
         self.fail('')
Exemple #7
0
 def test_get_customer_invalid_password (self):
     """
         No valid password --> Customer.WRONG_USERNAME_OR_PASSWORD
     """
     customer = Customer.get_customer ('pepito', 'passwordNoValid')
     self.assertEqual (customer, Customer.WRONG_USERNAME_OR_PASSWORD)  	
Exemple #8
0
 def test_get_customer_ok (self):
     """
         If you provide a correct username and password you'll get a Customer.
     """
     customer = Customer.get_customer (self.customer_name, self.customer_pass)
     self.assertEqual (customer, Customer.objects.get(username=self.customer_name) )
Exemple #9
0
 def test_check_customer_and_credit_ok(self):
     account = Account.objects.get(name=self.account_name, customer__username=self.customer_name)
     ret = Customer.check_customer_and_credit (self.customer_name, self.customer_pass, self.account_name)
     self.assertEqual (ret, account)
Exemple #10
0
 def test_check_customer_and_credit_wrong_account (self):
     ret = Customer.check_customer_and_credit (self.customer_name, self.customer_pass, 'noAccount', 100)
     self.assertEqual (ret, Customer.WRONG_ACCOUNT)
Exemple #11
0
 def test_check_customer_and_credit_wrong_password (self):
     ret = Customer.check_customer_and_credit ('customer1', 'no_password_de_customer1', 'noAccount', 100)
     self.assertEqual (ret, Customer.WRONG_USERNAME_OR_PASSWORD)
Exemple #12
0
 def test_check_customer_and_credit_wrong_username (self):
     ret = Customer.check_customer_and_credit ('pepito_malo', 'password', 'noAccount', 100)
     self.assertEqual (ret, Customer.WRONG_USERNAME_OR_PASSWORD)