Esempio n. 1
0
    def test_harvest_command_without_amount(self):
        invalid_messages = ['harvest potato', 'harvest potato']

        for body in invalid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertFalse(cmd.valid())
    def test_harvest_command_without_amount(self):
        invalid_messages = [
            'harvest potato',
            'harvest potato'
        ]

        for body in invalid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertFalse(cmd.valid())
Esempio n. 3
0
    def test_harvest_command_with_invalid_command(self):
        invalid_messages = [
            'sell 20 potato', 'sell potato 20', 'jual 20 potato',
            'jual potato 20'
        ]

        for body in invalid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertFalse(cmd.valid())
    def test_harvest_command_with_invalid_command(self):
        invalid_messages = [
            'sell 20 potato',
            'sell potato 20',
            'jual 20 potato',
            'jual potato 20'
        ]

        for body in invalid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertFalse(cmd.valid())
Esempio n. 5
0
    def test_harvest_command(self):
        valid_messages = [
            'harvest 20 potato', 'harvest potato 20', 'panen 20 potato',
            'panen potato 20'
        ]

        for body in valid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertTrue(cmd.valid())
            self.assertEqual(20, cmd.amount)
            self.assertEqual('potato', cmd.plant)
    def test_harvest_command(self):
        valid_messages = [
            'harvest 20 potato',
            'harvest potato 20',
            'panen 20 potato',
            'panen potato 20'
        ]

        for body in valid_messages:
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertTrue(cmd.valid())
            self.assertEqual(20, cmd.amount)
            self.assertEqual('potato', cmd.plant)
Esempio n. 7
0
    def test_harvest_command_should_ignore_cases(self):
        valid_messages = {
            'harvest 20 Potato': 'potato',
            'harvest 20 POTATO': 'potato',
            'harvest 20 Chinese Broccoli': 'chinese broccoli',
            'harvest 20 CHINESE BROCCOLI': 'chinese broccoli'
        }

        for body, v in valid_messages.iteritems():
            sms = SmsRequest()
            sms.body = body
            cmd = HarvestCommand(sms)
            self.assertEqual(v, cmd.plant)
 def _harvest(self, plant, amount):
     cmd = HarvestCommand(self.sms)
     cmd.plant = plant
     cmd.amount = amount
     return cmd
Esempio n. 9
0
 def _harvest(self, plant, amount):
     cmd = HarvestCommand(self.sms)
     cmd.plant = plant
     cmd.amount = amount
     return cmd