def test_hottest_small_n(self): """Test hottest with n less than or equal length of dictionary""" self.assertEqual(hw4.hottest(self.norcal,2), ['Fresno', 'Sacramento']) # Test if the original dictionary is modified self.assertEqual(self.norcal, self.unchanged_norcal) self.assertEqual(hw4.hottest(self.norcal, 8), ['Fresno','Sacramento','Napa','San Jose', 'Mountain View','Los Altos','Palo Alto','Oakland']) # Test if the original dictionary is modified self.assertEqual(self.norcal, self.unchanged_norcal)
def test_hottest_normal_cases(self): """Testing hottest function with arbitrary number of cities""" self.assertEqual(hw4.hottest(self.norcal,2), ['Fresno', 'Sacramento']) # Test if the original dictionary is modified self.assertEqual(self.norcal, self.unchanged_norcal) self.assertEqual(hw4.hottest(self.norcal, 8), ['Fresno','Sacramento','Napa','San Jose', 'Mountain View','Los Altos','Palo Alto','Oakland']) # Test if the original dictionary is modified self.assertEqual(self.norcal, self.unchanged_norcal)
def test_hottest_big_n(self): """Test hottest with n greater than length of dictionary""" self.assertEqual(hw4.hottest(self.norcal,20), ['Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland', 'San Francisco']) # Test if the original dictionary is modified self.assertEqual(self.norcal, self.unchanged_norcal)
def test_hottest_small_n(self): """Test hottest with n < dictionary length""" self.assertEqual(hw4.hottest(self.norcal, 2), ['Fresno', 'Sacramento']) self.assertEqual(hw4.hottest(self.norcal, 8), [ 'Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland' ]) self.assertEqual(hw4.hottest(self.norcal, 2), ['Fresno', 'Sacramento']) self.assertEqual( self.norcal, { 'Fresno': 77, 'Napa': 74, 'Palo Alto': 70, 'Sacramento': 75, 'San Francisco': 64, 'San Jose': 73, 'Oakland': 67, 'Los Altos': 71, 'Mountain View': 72 })
def test_hottest_no_modify(self): """Tests the to see if hottest the dictionary""" self.assertEqual(hw4.hottest(self.norcal, 8), [ 'Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland' ]) self.assertEqual( self.norcal, { 'Fresno': 77, 'Napa': 74, 'Palo Alto': 70, 'Sacramento': 75, 'San Francisco': 64, 'San Jose': 73, 'Oakland': 67, 'Los Altos': 71, 'Mountain View': 72 })
def test_hottest_nocities(self): """Tests hottest with an empty dictionary""" self.assertEqual(hw4.hottest(self.no_cities, 6), [])
def test_hottest_twenty(self): """Tests to see printing of 20 hottest""" self.assertEqual(hw4.hottest(self.norcal, 20), [ 'Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland', 'San Francisco' ])
def test_hottest_more(self): """Tests to find 8 hottest cities""" self.assertEqual(hw4.hottest(self.norcal, 8), [ 'Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland' ])
def test_hottest_default(self): """Tests to find hottest cities defaults to 4""" self.assertEqual(hw4.hottest(self.norcal), ['Fresno', 'Sacramento', 'Napa', 'San Jose'])
def test_hottest_few(self): """Tests to find a few cities""" self.assertEqual(hw4.hottest(self.norcal, 2), ['Fresno', 'Sacramento'])
def test_hottest_omit_n(self): """Testing the hottest function without specify integer n""" self.assertEqual(hw4.hottest(self.norcal), ['Fresno', 'Sacramento', 'Napa', 'San Jose']) # Test if the original dictionary is modified self.assertEqual(self.norcal,self.unchanged_norcal)
def test_hottest_no_cites(self): """Test the hottest function with empty dictionary""" self.assertEqual(hw4.hottest(self.no_cities, 6), []) # Test if the original dictionary is modified self.assertEqual(self.no_cities, {})
def test_hottest_large_n(self): """Test hottest with n > dictionary length""" self.assertEqual(hw4.hottest(self.norcal, 20), [ 'Fresno', 'Sacramento', 'Napa', 'San Jose', 'Mountain View', 'Los Altos', 'Palo Alto', 'Oakland', 'San Francisco' ])
def test_hottest_default(self): """Test hottest with default value""" self.assertEqual(hw4.hottest(self.norcal), ['Fresno', 'Sacramento', 'Napa', 'San Jose'])
def test_hottest_empty(self): """Test hottest with empty dictionary""" self.assertEqual(hw4.hottest(self.no_cities, 6), [])