Esempio n. 1
0
    def test_plant_command_without_amount(self):
        invalid_messages = ['plant potato', 'tanam potato']

        for body in invalid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertFalse(cmd.valid())
Esempio n. 2
0
    def test_plant_command_with_invalid_command(self):
        invalid_messages = [
            'sell 20 potato', 'sell potato 20', 'jual 20 potato',
            'jual potato 20'
        ]

        for body in invalid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertFalse(cmd.valid())
    def test_plant_command_without_amount(self):
        invalid_messages = [
            'plant potato',
            'tanam potato'
        ]

        for body in invalid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertFalse(cmd.valid())
Esempio n. 4
0
    def test_plant_command(self):
        valid_messages = [
            'plant 20 potato', 'plant potato 20', 'tanam 20 potato',
            'tanam potato 20'
        ]

        for body in valid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertTrue(cmd.valid())
            self.assertEqual(20, cmd.amount)
            self.assertEqual('potato', cmd.plant)
    def test_plant_command_with_invalid_command(self):
        invalid_messages = [
            'sell 20 potato',
            'sell potato 20',
            'jual 20 potato',
            'jual potato 20'
        ]

        for body in invalid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertFalse(cmd.valid())
    def test_plant_command(self):
        valid_messages = [
            'plant 20 potato',
            'plant potato 20',
            'tanam 20 potato',
            'tanam potato 20'
        ]

        for body in valid_messages:
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertTrue(cmd.valid())
            self.assertEqual(20, cmd.amount)
            self.assertEqual('potato', cmd.plant)
Esempio n. 7
0
    def test_multi_word_plant(self):
        invalid_messages = {
            'plant 20 chinese broccoli': ('chinese broccoli', 20),
            'plant chinese broccoli 20': ('chinese broccoli', 20),
            'tanam 20 sweet potato': ('sweet potato', 20),
            'tanam sweet potato 20': ('sweet potato', 20),
        }

        for body, v in invalid_messages.items():
            self.sms.body = body
            cmd = PlantCommand(self.sms)

            self.assertTrue(cmd.valid())
            self.assertEqual(v[0], cmd.plant)
            self.assertEqual(v[1], cmd.amount)
    def test_multi_word_plant(self):
        invalid_messages = {
            'plant 20 chinese broccoli': ('chinese broccoli', 20),
            'plant chinese broccoli 20': ('chinese broccoli', 20),
            'tanam 20 sweet potato': ('sweet potato', 20),
            'tanam sweet potato 20': ('sweet potato', 20),
        }

        for body, v in invalid_messages.items():
            self.sms.body = body
            cmd = PlantCommand(self.sms)

            self.assertTrue(cmd.valid())
            self.assertEqual(v[0], cmd.plant)
            self.assertEqual(v[1], cmd.amount)
Esempio n. 9
0
    def test_plant_command_should_ignore_cases(self):
        valid_messages = {
            'plant 20 Potato': 'potato',
            'plant 20 POTATO': 'potato',
            'plant 20 Chinese Broccoli': 'chinese broccoli',
            'plant 20 CHINESE BROCCOLI': 'chinese broccoli'
        }

        for body, v in valid_messages.iteritems():
            self.sms.body = body
            cmd = PlantCommand(self.sms)
            self.assertEqual(v, cmd.plant)
 def _plant(self, plant, amount):
     cmd = PlantCommand(self.sms)
     cmd.plant = plant
     cmd.amount = amount
     return cmd
 def _plant(self, plant, amount):
     cmd = PlantCommand(self.sms)
     cmd.plant = plant
     cmd.amount = amount
     return cmd