Exemplo n.º 1
0
        def test_it_shoud_handle_region(self):
            r = get_entity_value({
                'kind': 'Region',
                'value': 'California',
            })

            expect(r).to.equal('California')
Exemplo n.º 2
0
        def test_it_shoud_handle_city(self):
            r = get_entity_value({
                'kind': 'City',
                'value': 'Paris',
            })

            expect(r).to.equal('Paris')
Exemplo n.º 3
0
        def test_it_shoud_handle_country(self):
            r = get_entity_value({
                'kind': 'Country',
                'value': 'France',
            })

            expect(r).to.equal('France')
Exemplo n.º 4
0
        def test_it_should_handle_percentage(self):
            r = get_entity_value({
                'kind': 'Percentage',
                'value': 20.0,
            })

            expect(r).to.equal(0.2, epsilon=0.01)
Exemplo n.º 5
0
        def test_it_should_handle_music_track(self):
            r = get_entity_value({
                'kind': 'MusicTrack',
                'value': 'Harder Better Faster Stronger'
            })

            expect(r).to.equal('Harder Better Faster Stronger')
Exemplo n.º 6
0
        def test_it_should_handle_number(self):
            r = get_entity_value({
                'kind': 'Number',
                'value': 42.2,
            })

            expect(r).to.equal(42.2, epsilon=0.01)
Exemplo n.º 7
0
        def test_it_should_handle_ordinal(self):
            r = get_entity_value({
                'kind': 'Ordinal',
                'value': 2,
            })

            expect(r).to.equal(2)
Exemplo n.º 8
0
        def test_it_should_handle_temperature(self):
            r = get_entity_value({
                'kind': 'Temperature',
                'value': 23.5,
                'unit': 'celsius',
            })

            expect(r).to.be.a(UnitValue)
            expect(r.value).to.equal(23.5, epsilon=0.01)
            expect(r.unit).to.equal('celsius')
Exemplo n.º 9
0
        def test_it_should_handle_amount_of_money(self):
            r = get_entity_value({
                'kind': 'AmountOfMoney',
                'value': 10.05,
                'precision': 'Approximate',
                'unit': '€',
            })

            expect(r).to.be.a(UnitValue)
            expect(r.value).to.equal(10.05, epsilon=0.01)
            expect(r.unit).to.equal('€')
Exemplo n.º 10
0
        def test_it_should_handle_instant_time(self):
            r = get_entity_value({
                'kind': 'InstantTime',
                'value': '2017-06-13 18:00:00 +02:00',
                'grain': 'Hour',
                'precision': 'Exact',
            })

            expected = dateParse('2017-06-13 18:00:00 +02:00')

            expect(r).to.be.a(datetime.datetime)
            expect(r).to.equal(expected)
Exemplo n.º 11
0
        def test_it_should_handle_time_interval(self):
            r = get_entity_value({
                'kind': 'TimeInterval',
                'from': '2017-06-07 18:00:00 +02:00',
                'to': '2017-06-08 00:00:00 +02:00',
            })

            expected_from = dateParse('2017-06-07 18:00:00 +02:00')
            expected_to = dateParse('2017-06-08 00:00:00 +02:00')

            expect(r).to.be.a(tuple)
            expect(r[0]).to.equal(expected_from)
            expect(r[1]).to.equal(expected_to)
Exemplo n.º 12
0
        def test_it_should_handle_duration(self):
            r = get_entity_value({
                'kind': 'Duration',
                'years': 1,
                'quarters': 0,
                'months': 3,
                'weeks': 2,
                'days': 6,
                'hours': 10,
                'minutes': 30,
                'seconds': 59,
                'precision': 'Exact',
            })

            expected_delta = relativedelta(years=1,
                                           months=3,
                                           weeks=2,
                                           days=6,
                                           hours=10,
                                           minutes=30,
                                           seconds=59)

            expect(r).to.be.a(relativedelta)
            expect(r).to.equal(expected_delta)
Exemplo n.º 13
0
        def test_it_should_handle_custom(self):
            r = get_entity_value({'kind': 'Custom', 'value': 'kitchen'})

            expect(r).to.equal('kitchen')
Exemplo n.º 14
0
        def test_it_should_handle_music_artist(self):
            r = get_entity_value({'kind': 'MusicArtist', 'value': 'Daft Punk'})

            expect(r).to.equal('Daft Punk')
Exemplo n.º 15
0
        def test_it_should_handle_music_album(self):
            r = get_entity_value({'kind': 'MusicAlbum', 'value': 'Discovery'})

            expect(r).to.equal('Discovery')