def test_Items(): name = 'Texas' object = get_object.Item(name) assert object.data == get_data.get_all_data( [total_url, countries_url, states_url]) assert object.fullJSON == get_data.get_all_data( [total_url, countries_url, states_url]) assert name == object.caller
def test_jsonByName_spaces(): NewYork1 = covid19_data.jsonByName("new york") NewYork2 = covid19_data.jsonByName("New York") NewYork3 = covid19_data.jsonByName("NEWYORK") data = get_data.get_all_data([total_url, countries_url, states_url]) assert NewYork1 == data['NewYork'.upper()] assert NewYork2 == data['NewYork'.upper()] assert NewYork3 == data['NewYork'.upper()]
def test_dataByName_spaces(): NewYork1 = covid19_data.dataByName("new york") NewYork2 = covid19_data.dataByName("New York") NewYork3 = covid19_data.dataByName("NEWYORK") data = get_data.get_all_data([total_url, countries_url, states_url]) assert NewYork1.deaths == data['NewYork'.upper()]['Deaths'] assert NewYork2.deaths == data['NewYork'.upper()]['Deaths'] assert NewYork3.deaths == data['NewYork'.upper()]['Deaths']
def test_jsonByNameShort(): Texas = covid19_data.jsonByNameShort("Tx") California = covid19_data.jsonByNameShort("CA") NewYork = covid19_data.jsonByNameShort("nY") data = get_data.get_all_data([total_url, countries_url, states_url]) assert California == data['California'.upper()] assert Texas == data['Texas'.upper()] assert NewYork == data['NewYork'.upper()]
def test_jsonByName(): Texas = covid19_data.jsonByName("TeXaS") Total = covid19_data.jsonByName("tOtAl") China = covid19_data.jsonByName("ChInA") data = get_data.get_all_data([total_url, countries_url, states_url]) assert Total == data['Total'.upper()] assert Texas == data['Texas'.upper()] assert China == data['China'.upper()]
def test_Item(): total = 'Total'.upper() state = 'Texas'.upper() country = 'US'.upper() data = get_data.get_all_data([total_url, countries_url, states_url]) Total = get_object.Item(total) Total.rtrn_data() State = get_object.Item(state) State.rtrn_data() Country = get_object.Item(country) Country.rtrn_data() assert Total.deaths == data[total]['Deaths'] assert State.deaths == data[state]['Deaths'] assert Country.deaths == data[country]['Deaths']
def test_attrState_short(): data = get_data.get_all_data([total_url, countries_url, states_url]) assert JHU.TX.deaths == data['Texas'.upper()]['Deaths'] assert JHU.CA.deaths == data['California'.upper()]['Deaths'] assert JHU.TX.deaths == JHU.Texas.deaths assert JHU.CA.deaths == JHU.California.deaths
def test_attrUS(): data = get_data.get_all_data([total_url, countries_url, states_url]) assert JHU.US.deaths == data['US'.upper()]['Deaths']
def test_attrCountry(): data = get_data.get_all_data([total_url, countries_url, states_url]) assert JHU.China.deaths == data['China'.upper()]['Deaths'] assert JHU.UnitedKingdom.deaths == data['UnitedKingdom'.upper()]['Deaths']
def test_attrTotal(): data = get_data.get_all_data([total_url, countries_url, states_url]) assert JHU.Total.deaths == data['Total'.upper()]['Deaths']
def test_get_all_data(): data = get_data.get_all_data([test_url])['Total'.upper()]['Confirmed'] test_data = json.loads(urllib.request.urlopen( test_url).read().decode())['features'][0]['attributes']['Confirmed'] assert data == test_data # test comment