def test_it_shoud_handle_region(self): r = get_entity_value({ 'kind': 'Region', 'value': 'California', }) expect(r).to.equal('California')
def test_it_shoud_handle_city(self): r = get_entity_value({ 'kind': 'City', 'value': 'Paris', }) expect(r).to.equal('Paris')
def test_it_shoud_handle_country(self): r = get_entity_value({ 'kind': 'Country', 'value': 'France', }) expect(r).to.equal('France')
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)
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')
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)
def test_it_should_handle_ordinal(self): r = get_entity_value({ 'kind': 'Ordinal', 'value': 2, }) expect(r).to.equal(2)
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')
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('€')
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)
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)
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)
def test_it_should_handle_custom(self): r = get_entity_value({'kind': 'Custom', 'value': 'kitchen'}) expect(r).to.equal('kitchen')
def test_it_should_handle_music_artist(self): r = get_entity_value({'kind': 'MusicArtist', 'value': 'Daft Punk'}) expect(r).to.equal('Daft Punk')
def test_it_should_handle_music_album(self): r = get_entity_value({'kind': 'MusicAlbum', 'value': 'Discovery'}) expect(r).to.equal('Discovery')