def main(): lookup = Lookup() lookup.readEmployee('employees.csv') lookup.readAirport() lookup.readCountryCurrency() lookup.readCurrencyRate() agent = TravelAgent(lookup) print(agent.costLeg('LAX','DUB')) result = agent.findBestRoute(agent.findPossibleRoutes(Employee("Alice","DUB","JFK","AAL","CDG","SYD"))) print(result) print(agent.getResultByName('Tom'))
# Copyright: (c) Lisa 2015 # Licence: <your licence> #------------------------------------------------------------------------------- from Lookup import * from Employee import * from Airport import * from Currency import * from TravelAgent import * import csv # ----------- setting up the lookup details ------------------------------------ lookup = Lookup() lookup.readEmployee('employees.csv') lookup.readAirport() lookup.readCountryCurrency() lookup.readCurrencyRate() agent = TravelAgent(lookup) # ------------ Confirming that data is ready ----------------------------------- print('All csv data has been read.') print('Total Employees:', len(lookup.employee_info)) print('Total Airports:', len(lookup.airport_info)) print('Total Currencies:', len(lookup.currency_info)) print('Total Exchange Rates:', len(lookup.currencyrate_info)) # ------------ Basic information retrieval exercises --------------------------- print('Currency for LHR airport: ',lookup.getCurrency('LHR')) # GBP print('Exchange Rate for GBP to EUR: ',lookup.getExchangeRate('LHR')) # 1.4029
# Created: 01/05/2015 # Copyright: (c) Lisa 2015 # Licence: <your licence> # ------------------------------------------------------------------------------- from Lookup import * from Employee import * from Airport import * from Currency import * from TravelAgent import * import unittest import pytest lookup = Lookup() lookup.readEmployee("employees.csv") lookup.readAirport() lookup.readCountryCurrency() lookup.readCurrencyRate() agent = TravelAgent(lookup) class FileReadToClasses(unittest.TestCase): """ Tests that lookup is saving all data from csv files into objects """ def test_employees(self): employees = 4 self.assertEqual(employees, len(lookup.employee_info.values())) def test_airports(self):