def test_short_name_shop_status_check_sms(self):
     """ make sure a query with shop name shorter than MIN_NAME_QUERY chars
         doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'status %s' % ('a'*(MIN_NAME_QUERY-1)))
     self.assertRaises(QueryNameTooShortException, message_parser.parse, 
                       message)
Exemplo n.º 2
0
 def test_short_address_reg_shop_sms(self):
     """ make sure a query with shop address shorter than 
         MIN_ADDRESS_ACTUAL chars doesn't proceed """
     message = IncomingSMS(
         "94770000000", util.current_time(), ("reg shop n:shop1 a:%s" % ("a" * (MIN_ADDRESS_ACTUAL - 1)))
     )
     self.assertRaises(ActualAddressTooShortException, message_parser.parse, message)
 def test_long_name_shop_status_update_sms(self):
     """ make sure a query with status longer than MAX_STATUS chars
         doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'update %s' % ('a'*(MAX_STATUS+1)))
     self.assertRaises(StatusTooLongException, message_parser.parse, 
                       message)
Exemplo n.º 4
0
 def test_unreg_shop_sms(self):
     """ test customer unregistration query with name only """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'unreg shop')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.SHOP_UNREGISTER)
     self.assertEqual(parsed.params['phone'], '94770000000')
Exemplo n.º 5
0
 def test_long_address_reg_cust_sms(self):
     """ make sure a query with customer address longer than 
         MAX_ADDRESS_ACTUAL chars doesn't proceed """
     message = IncomingSMS(
         "94770000000", util.current_time(), ("reg cust n:name1 a:%s" % ("a" * (MAX_ADDRESS_ACTUAL + 1)))
     )
     self.assertRaises(ActualAddressTooLongException, message_parser.parse, message)
Exemplo n.º 6
0
 def test_long_name_untrack_shop_sms(self):
     """ make sure a query with shop name longer than MAX_NAME_QUERY
         chars doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'untrack n:%s' % ('a'*(MAX_NAME_QUERY+1)))
     self.assertRaises(QueryNameTooLongException, message_parser.parse, 
                       message)
Exemplo n.º 7
0
 def test_long_category_reg_shop_sms(self):
     """ make sure a query with shop category longer than 
         MAX_CATEGORY_ACTUAL chars doesn't proceed """
     message = IncomingSMS(
         "94770000000", util.current_time(), ("reg shop n:shop1 c:%s" % ("a" * (MAX_CATEGORY_ACTUAL + 1)))
     )
     self.assertRaises(ActualCategoryTooLongException, message_parser.parse, message)
Exemplo n.º 8
0
 def test_long_category_find_shop_sms(self):
     """ make sure a shop find query with shop category longer than 
         MAX_CATEGORY_QUERY chars doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           ('find %s' 
                            % ('a'*(MAX_CATEGORY_QUERY+1))))
     self.assertRaises(QueryCategoryTooLongException, 
                       message_parser.parse, message)
Exemplo n.º 9
0
 def test_short_address_track_shop_sms(self):
     """ make sure a query with shop address shorter than 
         MIN_ADDRESS_QUERY chars doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           ('track n:name1 a:%s' 
                            % ('a'*(MIN_ADDRESS_QUERY-1))))
     self.assertRaises(QueryAddressTooShortException, message_parser.parse, 
                       message)
Exemplo n.º 10
0
 def test_find_shop_sms(self):
     """ test shop find query with category """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'find hardware')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.FIND_SHOP)
     self.assertEqual(parsed.params['phone'], '94770000000')
     self.assertEqual(parsed.params['category'], 'hardware')
 def test_shop_status_update_sms(self):
     """ test shop status update query """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'update open from 7 am to 8 am')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.UPDATE_STATUS)
     self.assertEqual(parsed.params['phone'], '94770000000')
     self.assertEqual(parsed.params['status'], 'open from 7 am to 8 am')
Exemplo n.º 12
0
 def test_reg_cust_sms_with_name_and_address(self):
     """ test customer registration query with name and address """
     message = IncomingSMS("94770000000", util.current_time(), "reg cust n:janaka a:molpe, moratuwa 10400")
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.CUST_REGISTER)
     self.assertEqual(parsed.params["phone"], "94770000000")
     self.assertEqual(parsed.params["name"], "janaka")
     self.assertEqual(parsed.params["address"], "molpe, moratuwa 10400")
Exemplo n.º 13
0
 def test_shop_status_check_sms(self):
     """ test shop status check query with name """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'status Bank of Ceylon, Katubedda')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.SHOP_STATUS)
     self.assertEqual(parsed.params['phone'], '94770000000')
     self.assertEqual(parsed.params['shop'], 'Bank of Ceylon, Katubedda')
Exemplo n.º 14
0
 def test_long_address_untrack_shop_sms(self):
     """ make sure a query with shop address longer than 
         MAX_ADDRESS_QUERY chars doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 
                           ('untrack n:name1 a:%s' 
                            % ('a'*(MAX_ADDRESS_QUERY+1))))
     self.assertRaises(QueryAddressTooLongException, message_parser.parse, 
                       message)
Exemplo n.º 15
0
 def test_track_shop_sms_with_name_only_2(self):
     """ test shop track query with name only """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'track n:Royal Diner')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.TRACK_SHOP)
     self.assertEqual(parsed.params['phone'], '94770000000')
     self.assertEqual(parsed.params['shop'], 'Royal Diner')
     self.assertEqual(parsed.params['address'], None)
Exemplo n.º 16
0
 def test_untrack_shop_sms_with_name_and_address(self):
     """ test shop untrack query with name and address """
     message = IncomingSMS('94770000000', util.current_time(), 
                           'untrack n:Royal Diner a:Moratuwa')
     parsed = message_parser.parse(message)
     self.assertEqual(parsed.type, query.UNTRACK_SHOP)
     self.assertEqual(parsed.params['phone'], '94770000000')
     self.assertEqual(parsed.params['shop'], 'Royal Diner')
     self.assertEqual(parsed.params['address'], 'Moratuwa')
Exemplo n.º 17
0
 def test_no_category_find_shop_sms(self):
     """ make sure a shop find query without a category doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 'find')
     self.assertRaises(QueryCategoryTooShortException, message_parser.parse,
                       message)
Exemplo n.º 18
0
 def test_bad_format_reg_sms(self):
     """ make sure a registration SMS of bad format doesn't proceed """
     message = IncomingSMS("94770000000", util.current_time(), "reg")
     self.assertRaises(RegistrationException, message_parser.parse, message)
Exemplo n.º 19
0
 def test_no_name_untrack_shop_sms(self):
     """ make sure shop untrack query with no shop name doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 'untrack')
     self.assertRaises(QueryNameTooShortException, message_parser.parse, 
                       message)
Exemplo n.º 20
0
 def test_short_name_reg_cust_sms(self):
     """ make sure a query with customer name shorter than MIN_NAME_ACTUAL 
         chars doesn't proceed """
     message = IncomingSMS("94770000000", util.current_time(), "reg cust n:%s" % ("a" * (MIN_NAME_ACTUAL - 1)))
     self.assertRaises(ActualNameTooShortException, message_parser.parse, message)
 def test_no_name_shop_status_update_sms(self):
     """ make sure shop status update query without name doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 'update')
     self.assertRaises(StatusTooShortException, message_parser.parse,
                       message)
Exemplo n.º 22
0
 def test_no_details_reg_shop_sms(self):
     """ make sure a query without shop data doesn't proceed """
     message = IncomingSMS("94770000000", util.current_time(), "reg shop")
     self.assertRaises(MissingShopNameException, message_parser.parse, message)
Exemplo n.º 23
0
 def test_no_name_reg_shop_sms(self):
     """ make sure a query without shop name doesn't proceed """
     message = IncomingSMS("94770000000", util.current_time(), "reg shop n:")
     self.assertRaises(ActualNameTooShortException, message_parser.parse, message)
Exemplo n.º 24
0
 def test_bad_format_unreg_sms(self):
     """ make sure a unregistration SMS of bad format doesn't proceed """
     message = IncomingSMS('94770000000', util.current_time(), 'unreg')
     self.assertRaises(UnregistrationException, message_parser.parse, 
                       message)
Exemplo n.º 25
0
 def test_long_name_reg_shop_sms(self):
     """ make sure a query with shop name longer than MAX_NAME_ACTUAL chars
         doesn't proceed """
     message = IncomingSMS("94770000000", util.current_time(), "reg shop n:%s" % ("a" * (MAX_NAME_ACTUAL + 1)))
     self.assertRaises(ActualNameTooLongException, message_parser.parse, message)