Esempio n. 1
0
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']
Esempio n. 2
0
from datetime import datetime
import copy

import pyroyale
from crtools import history, load_config_file
from crtools.models import ProcessedCurrentWar

__fake_members__ = [
    pyroyale.ClanMember(
        name      = 'Player A',
        tag       = '#AAAAAA',
        role      = 'leader',
        donations = 100
    ),
    pyroyale.ClanMember(
        name      = 'Player C',
        tag       = '#CCCCCC',
        role      = 'member',
        donations = 10
    ),
    pyroyale.ClanMember(
        name      = 'Player D',
        tag       = '#DDDDDD',
        role      = 'elder',
        donations = 10
    )
]

__fake_history__ = {
    "last_update": 1549974720.0,
    "members": {
__fake_clan__ = pyroyale.Clan(
    tag=CLAN_TAG,
    name="Agrassar",
    description="Rules, stats, discord link, and info at https://agrassar.com",
    clan_score=38803,
    clan_war_trophies=1813,
    required_trophies=3000,
    donations_per_week=7540,
    members=4,
    member_list=[
        pyroyale.ClanMember(tag="#AAAAAA",
                            name="LeaderPerson",
                            role="leader",
                            exp_level=12,
                            trophies=4153,
                            donations=300,
                            arena=pyroyale.Arena(id=54000012,
                                                 name='Legendary Arena'),
                            last_seen="20190802T154619.000Z"),
        pyroyale.ClanMember(tag="#BBBBBB",
                            name="CoLeaderPerson",
                            role="coLeader",
                            exp_level=12,
                            trophies=4418,
                            donations=150,
                            arena=pyroyale.Arena(id=54000013, name='Arena 12'),
                            last_seen="20190802T154619.000Z"),
        pyroyale.ClanMember(tag="#CCCCCC",
                            name="ElderPerson",
                            role="elder",
Esempio n. 4
0
'''

__fake_clan__ = pyroyale.Clan(
    tag=CLAN_TAG,
    name="Agrassar",
    description="Rules, stats, discord link, and info at https://agrassar.com",
    clan_score=38803,
    clan_war_trophies=1813,
    required_trophies=3000,
    donations_per_week=7540,
    members=4,
    member_list=[
        pyroyale.ClanMember(tag="#AAAAAA",
                            name="LeaderPerson",
                            role="leader",
                            exp_level=12,
                            trophies=4153,
                            donations=300,
                            last_seen="20190802T154619.000Z")
    ])

__fake_war_clan__ = pyroyale.WarClan(tag=CLAN_TAG,
                                     name="Agrassar",
                                     clan_score=1813,
                                     participants=17,
                                     battles_played=13,
                                     battles_remaining=0,
                                     wins=1,
                                     crowns=5)

__fake_current_war__ = pyroyale.WarCurrent(