def test_get_suggestions_nosuggestions(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write( __config_file_score__ + '\nthreshold_demote=-999999\nthreshold_promote=9999999\nmin_clan_size={}' .format(crtools.MAX_CLAN_SIZE)) config = load_config_file(config_file.realpath()) members = [] for i in range(0, crtools.MAX_CLAN_SIZE): members.append({ "role": "leader", "trophies": 9999, "donations": 999, "score": 999, "vacation": False, "safe": True, "blacklist": False, "no_promote": False }) suggestions = crtools.get_suggestions(config, members, __fake_clan__) assert len(suggestions) == 1 assert suggestions[0] == config['strings']['suggestionNone']
def test_get_suggestions_kick(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write(__config_file_score__ + '\nmin_clan_size=1') config = load_config_file(config_file.realpath()) h = history.get_member_history(__fake_clan__['member_list'], None) members = crtools.process_members(config, __fake_clan__, __fake_warlog__, {"state": "notInWar"}, h) suggestions = crtools.get_suggestions(config, members, __fake_clan__) print(suggestions) assert suggestions[0].startswith('Kick') assert members[3]['name'] in suggestions[0]
def test_get_suggestions_recruit(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write(__config_file_score__ + '\nthreshold_demote=-999999\nthreshold_promote=9999999') config = load_config_file(config_file.realpath()) h = history.get_member_history(__fake_clan__['member_list'], None) members = crtools.process_members(config, __fake_clan__, __fake_warlog__, {"state": "notInWar"}, h) suggestions = crtools.get_suggestions(config, members, __fake_clan__) print(suggestions) assert len(suggestions) == 1 assert suggestions[0] == config['strings']['suggestionRecruit']
def test_get_suggestions_kick(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write(__config_file_score__ + '\nmin_clan_size=1') config = load_config_file(config_file.realpath()) h = history.get_member_history(__fake_clan__.member_list, None) members = crtools.process_members(config, __fake_clan__, __fake_warlog__, __fake_currentwar_notinwar__, h) suggestions = crtools.get_suggestions(config, members, __fake_clan__.required_trophies) print(suggestions) assert suggestions[0].startswith('Kick') assert members[3].name in suggestions[0]
def test_get_suggestions_promote_demote(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write(__config_file_score__ + '\nthreshold_promote=10') config = load_config_file(config_file.realpath()) h = history.get_member_history(__fake_clan__['member_list'], None) members = crtools.process_members(config, __fake_clan__, __fake_warlog__, {"state": "notInWar"}, h) suggestions = crtools.get_suggestions(config, members, __fake_clan__) print(suggestions) assert suggestions[0].startswith('Demote') assert members[2]['name'] in suggestions[0] assert suggestions[1].startswith('Promote') or suggestions[2].startswith( 'Promote') assert members[4]['name'] in suggestions[1] or members[4][ 'name'] in suggestions[2]
def test_get_suggestions_promote_demote(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write(__config_file_score__ + '\nthreshold_promote=10') config = load_config_file(config_file.realpath()) h = history.get_member_history(__fake_clan__.member_list, None) members = crtools.process_members(config, __fake_clan__, __fake_warlog__, __fake_currentwar_notinwar__, h) suggestions = crtools.get_suggestions(config, members, __fake_clan__.required_trophies) print(suggestions) assert suggestions[0].startswith('Demote') assert members[2].name in suggestions[0] assert suggestions[1].startswith('Promote') or suggestions[2].startswith( 'Promote') assert members[4].name in suggestions[1] or members[4].name in suggestions[ 2]
def test_get_suggestions_nosuggestions(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write( __config_file_score__ + '\nthreshold_demote=-999999\nthreshold_promote=9999999\nmin_clan_size={}' .format(crtools.MAX_CLAN_SIZE)) config = load_config_file(config_file.realpath()) war = ProcessedCurrentWar( config=config, current_war=pyroyale.WarCurrent(state='notInWar')) factory = MemberFactory(config=config, member_history=history.get_member_history( __fake_clan__.member_list, config['crtools']['timestamp'], '{}', war), current_war=war, clan=__fake_clan__, warlog=pyroyale.WarLog(items=[])) members = [] for i in range(0, crtools.MAX_CLAN_SIZE): member = factory.get_processed_member( pyroyale.ClanMember(tag="#AAAAAA", name="LeaderPerson", role="leader", exp_level=13, trophies=9999, donations=9999, arena=pyroyale.Arena(id=54000012, name='Legendary Arena'), last_seen="20190802T154619.000Z")) member.safe = True members.append(member) suggestions = crtools.get_suggestions(config, members, __fake_clan__.required_trophies) assert len(suggestions) == 1 assert suggestions[-1] == config['strings']['suggestionNone']