Exemplo n.º 1
0
 def test_parse_abbreviation_ll(self):
     c = Coffee('LL')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Latte',
         'size': 'Large',
     })
Exemplo n.º 2
0
 def test_parse(self):
     c = Coffee('Large Cap')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'size': 'Large',
     })
Exemplo n.º 3
0
 def test_parse_abbreviation4(self):
     c = Coffee('lfw')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Flat White',
         'size': 'Large',
     })
Exemplo n.º 4
0
 def test_parse_abbreviation2(self):
     c = Coffee('SC')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'size': 'Small',
     })
Exemplo n.º 5
0
 def test_parse_words_iced_coffee2(self):
     c = Coffee('Skim Iced Chocolate')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Iced Chocolate',
         'milk': 'Skim',
     })
Exemplo n.º 6
0
 def test_parse_words_lactose_free(self):
     c = Coffee('Lactose Free Cap')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'milk': 'Lactose Free',
     })
Exemplo n.º 7
0
 def test_parse_words(self):
     c = Coffee('Small Latte')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Latte',
         'size': 'Small',
     })
Exemplo n.º 8
0
 def test_parse_abbreviation3(self):
     c = Coffee('lffw')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Flat White',
         'milk': 'Lactose Free',
     })
Exemplo n.º 9
0
 def test_parse_words4(self):
     c = Coffee('Regular Flat White')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Flat White',
         'size': 'Regular',
     })
Exemplo n.º 10
0
 def test_parse_words3(self):
     c = Coffee('Large Flat white')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Flat White',
         'size': 'Large',
     })
Exemplo n.º 11
0
 def test_parse_abbreviation_cl(self):
     c = Coffee('CL')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'size': 'Large',
     })
Exemplo n.º 12
0
 def test_parse_words_and_abbreviations_and_bigrams(self):
     c = Coffee('Large FW 3 Sugars')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Flat White',
         'size': 'Large',
         'sugar': '3 Sugars',
     })
Exemplo n.º 13
0
 def test_shelley2(self):
     c = Coffee('yo beanie boy give me a smol iced latte pls')
     self.assertEqual(c.specs, {
         'size': 'Small',
         'iced': 'Iced',
         'type': 'Latte',
     })
     self.assertTrue(c.validate())
Exemplo n.º 14
0
 def test_parse_bigram_sugars(self):
     c = Coffee('Large Cap 2 Sugars')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'size': 'Large',
         'sugar': '2 Sugars',
     })
Exemplo n.º 15
0
 def test_iced_choc_vs_iced_hot_choc(self):
     self.assertEqual(str(Coffee('icy choc')), 'Regular Iced Chocolate')
     self.assertEqual(str(Coffee('chocolate iced')),
                      'Regular Iced Hot Chocolate')
     self.assertEqual(str(Coffee('icy cold chocolate')),
                      'Regular Iced Hot Chocolate')
     self.assertEqual(str(Coffee('iced chocco')), 'Regular Iced Chocolate')
     self.assertEqual(str(Coffee('hot chocco')), 'Regular Hot Chocolate')
Exemplo n.º 16
0
 def test_parse_words2(self):
     c = Coffee('Small doubleshot cap')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Cappuccino',
         'size': 'Small',
         'strength': 'Extra-shot',
     })
Exemplo n.º 17
0
 def test_parse_words_iced(self):
     c = Coffee('Large Iced Latte')
     self.assertTrue(c.validate())
     self.assertEqual(c.specs, {
         'type': 'Latte',
         'size': 'Large',
         'iced': 'Iced',
     })
Exemplo n.º 18
0
 def test_joel(self):
     c = Coffee(
         'It is a truth universally acknowledged, that a single joel in possession of a good fortune, must be in want of an extra-shot piccolo latte in the morning, plox.'
     )
     self.assertEqual(c.specs, {
         'type': 'Piccolo Latte',
         'strength': 'Extra-shot',
     })
     self.assertTrue(c.validate())
Exemplo n.º 19
0
 def test_liam(self):
     c = Coffee(
         'let\'s try this again. I would very much enjoy if you could provide me with an Iced latte please thank you for listening to my TED Talk'
     )
     self.assertEqual(c.specs, {
         'type': 'Latte',
         'iced': 'Iced',
     })
     self.assertTrue(c.validate())
Exemplo n.º 20
0
 def test_parse_words_many(self):
     c = Coffee('Soy decaf latte with 2 sugars')
     self.assertTrue(c.validate())
     self.assertEqual(
         c.specs, {
             'type': 'Latte',
             'sugar': '2 Sugars',
             'decaf': 'Decaf',
             'milk': 'Soy',
         })
Exemplo n.º 21
0
    def test_minimal_spec(self):
        c = Coffee('')
        self.assertFalse(c.validate())
        self.assertTrue(c.add_spec('type', 'C'))
        self.assertTrue(c.validate())
        self.assertTrue(c.add_spec('size', 'l'))
        self.assertTrue(c.validate())

        # Still valid if we add more.
        self.assertTrue(c.add_spec('milk', 'soy'))
Exemplo n.º 22
0
    def test_parse(self):
        c = Coffee('Large Cap')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Large')

        c = Coffee('LC')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Large')

        c = Coffee('SC')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Small')

        c = Coffee('Large Cap 2 Sugars')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Large')
        self.assertEquals(c.specs['sugar'], '2 Sugars')

        c = Coffee('Small strong cap')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Small')
        self.assertEquals(c.specs['strength'], 'Extra-shot')

        c = Coffee('Small doubleshot cap')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Small')
        self.assertEquals(c.specs['strength'], 'Extra-shot')

        c = Coffee('Small Latte')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['size'], 'Small')

        c = Coffee('SL')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['size'], 'Small')

        c = Coffee('RegL')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['size'], 'Regular')

        c = Coffee('LL')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['size'], 'Large')

        c = Coffee('CL')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Large')

        c = Coffee('CL 2S')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Cappuccino')
        self.assertEquals(c.specs['size'], 'Large')
        self.assertEquals(c.specs['sugar'], '2 Sugars')

        c = Coffee('Large Iced Latte')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['size'], 'Large')
        self.assertEquals(c.specs['iced'], 'Iced')

        c = Coffee('Large Flat white')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Flat White')
        self.assertEquals(c.specs['size'], 'Large')

        c = Coffee('Large FW 3 Sugars')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Flat White')
        self.assertEquals(c.specs['size'], 'Large')
        self.assertEquals(c.specs['sugar'], '3 Sugars')

        c = Coffee('Regular Flat White')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Flat White')
        self.assertEquals(c.specs['size'], 'Regular')

        c = Coffee('Soy decaf latte with 2 sugars')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Latte')
        self.assertEquals(c.specs['sugar'], '2 Sugars')
        self.assertEquals(c.specs['decaf'], 'Decaf')
        self.assertEquals(c.specs['milk'], 'Soy')

        c = Coffee('yfw')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Flat White')
        self.assertEquals(c.specs['milk'], 'Soy')

        c = Coffee('Soy Iced Coffee')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Iced Coffee')
        self.assertEquals(c.specs['milk'], 'Soy')

        c = Coffee('Skim Iced Chocolate')
        self.assertTrue(c.validate())
        self.assertEquals(c.specs['type'], 'Iced Chocolate')
        self.assertEquals(c.specs['milk'], 'Skim')
Exemplo n.º 23
0
 def test_print_reg_latte(self):
     c = Coffee('Reg L')
     self.assertEqual('Regular Latte', str(c))
Exemplo n.º 24
0
 def test_print_large_latte(self):
     c = Coffee('LL')
     self.assertEqual('Large Latte', str(c))
Exemplo n.º 25
0
    def testPrint(self):
        c = Coffee('Large Cap')
        self.assertEquals('Large Cappuccino', str(c))

        c = Coffee('SC')
        self.assertEquals('Small Cappuccino', str(c))

        c = Coffee('Large Cap 2 Sugars')
        self.assertEquals('Large Cappuccino with 2 Sugars', str(c))

        c = Coffee('Small strong cap')
        self.assertEquals('Small Extra-shot Cappuccino', str(c))

        c = Coffee('Small Latte')
        self.assertEquals('Small Latte', str(c))

        c = Coffee('RegL')
        self.assertEquals('Regular Latte', str(c))

        c = Coffee('LL')
        self.assertEquals('Large Latte', str(c))

        c = Coffee('Large Iced Latte')
        self.assertEquals('Large Iced Latte', str(c))

        c = Coffee('Large Flat white')
        self.assertEquals('Large Flat White', str(c))

        c = Coffee('Large FW 3 Sugars')
        self.assertEquals('Large Flat White with 3 Sugars', str(c))

        c = Coffee('Regular Flat White')
        self.assertEquals('Regular Flat White', str(c))

        c = Coffee('Soy decaf latte with 2 sugars')
        self.assertEquals('Regular Soy Decaf Latte with 2 Sugars', str(c))

        c = Coffee('Can I')
        self.assertFalse(c.validate())
Exemplo n.º 26
0
 def test_print_large_iced_latte(self):
     c = Coffee('Large Iced Latte')
     self.assertEqual('Large Iced Latte', str(c))
Exemplo n.º 27
0
 def test_print_large_flat_white(self):
     c = Coffee('Large Flat white')
     self.assertEqual('Large Flat White', str(c))
Exemplo n.º 28
0
 def test_print_large_flat_white_3s(self):
     c = Coffee('Large FW 3 Sugars')
     self.assertEqual('Large Flat White with 3 Sugars', str(c))
Exemplo n.º 29
0
 def test_print_regular_flat_white(self):
     c = Coffee('Regular Flat White')
     self.assertEqual('Regular Flat White', str(c))
Exemplo n.º 30
0
 def test_print_soy_decaf_latte_2s(self):
     c = Coffee('Soy decaf latte with 2 sugars')
     self.assertEqual('Regular Soy Decaf Latte with 2 Sugars', str(c))