def test_get_player_skin(self): self.urlopen_mock.return_value.getcode.return_value = 200 PLAYER = 'Notch' ret = get_player_skin(PLAYER) self.urlopen_mock.assert_called_once_with(SKIN_URL % PLAYER) T.assert_equal(ret, self.urlopen_mock(None).read())
def test_data_dir_contains_same_skin(self): # Put notch's skin in the directory notch_skin = get_player_skin(self.username) with open(self._get_skin_file_path(), 'w') as skin_file: skin_file.write(notch_skin) # Note this will flake if notch changed his skin between above call and # now main([self.username]) T.assert_equal(self.print_mock.call_count, 0)
def main(argv): parser = argparse.ArgumentParser( description='Detect whether minecraft skins have changed.', ) parser.add_argument( 'usernames', type=str, nargs='+', help='Usernames to check for skin changes', ) args = parser.parse_args(argv) create_data_directory_if_not_exists() for username in args.usernames: user_skin = get_player_skin(username) if has_changed(username, user_skin): print('{0} has a new skin!'.format(username))
def test_get_player_skin_integration(self): ret = get_player_skin('Notch') assert ret
def test_get_player_skin_raises_with_non_200(self): self.urlopen_mock.return_value.getcode.return_value = 500 with T.assert_raises(FailedRequestError): get_player_skin('Notch')