示例#1
0
def test_send_war_nag_participants_completed_returns_false_because_url_invalid(
        tmpdir):

    config_file = tmpdir.mkdir(
        'test_send_war_nag_threshold_not_met_returns_true').join('testfile')
    config_file.write(__config_file__)
    config = load_config_file(config_file.realpath())

    fake_current_war = pyroyale.WarCurrent(
        state='collectionDay',
        collection_end_time=datetime.utcnow().strftime("%Y%m%dT%H%M%S.xxxx"),
        participants=[
            pyroyale.WarParticipant(name='AAA',
                                    tag='#AAA',
                                    battles_played=1,
                                    number_of_battles=3),
            pyroyale.WarParticipant(name='BBB',
                                    tag='#BBB',
                                    battles_played=1,
                                    number_of_battles=3)
        ])

    fake_members = [pyroyale.WarParticipant(tag='#AAA')]

    assert discord.send_war_nag(config, fake_current_war,
                                fake_members) == False
def test_send_war_nag_not_in_war_returns_false(tmpdir):
    config_file = tmpdir.mkdir(
        'test_send_war_nag_not_in_war_returns_false').join('testfile')
    config_file.write(__config_file__)
    config = load_config_file(config_file.realpath())

    assert discord.send_war_nag(config, {'state': 'notInWar'}, None) == True
def test_send_war_nag_participants_completed_returns_false_because_url_invalid(
        tmpdir):

    config_file = tmpdir.mkdir(
        'test_send_war_nag_threshold_not_met_returns_true').join('testfile')
    config_file.write(__config_file__)
    config = load_config_file(config_file.realpath())

    fake_current_war = {
        'state':
        'collectionDay',
        'collection_end_time':
        datetime.utcnow().strftime("%Y%m%dT%H%M%S.xxxx"),
        'participants': [{
            'name': 'AAA',
            'tag': '#AAA',
            'battles_played': 1,
            'number_of_battles': 3
        }, {
            'name': 'BBB',
            'tag': '#BBB',
            'battles_played': 1,
            'number_of_battles': 3
        }]
    }

    fake_members = [{'tag': '#AAA'}]

    assert discord.send_war_nag(config, fake_current_war,
                                fake_members) == False
示例#4
0
def test_send_war_nag_war_no_members_returns_true(tmpdir):
    config_file = tmpdir.mkdir(
        'test_send_war_nag_war_no_members_returns_true').join('testfile')
    config_file.write(__config_file__)
    config = load_config_file(config_file.realpath())

    fake_current_war = pyroyale.WarCurrent(
        state='warDay',
        war_end_time=datetime.utcnow().strftime("%Y%m%dT%H%M%S.xxxx"),
        participants=[])

    assert discord.send_war_nag(config, fake_current_war, []) == True
def test_send_war_nag_threshold_not_met_returns_true(tmpdir):

    config_file = tmpdir.mkdir(
        'test_send_war_nag_threshold_not_met_returns_true').join('testfile')
    config_file.write(__config_file_no_threshold__)
    config = load_config_file(config_file.realpath())

    fake_current_war = {
        'state': 'collectionDay',
        'collection_end_time':
        datetime.utcnow().strftime("%Y%m%dT%H%M%S.xxxx"),
        'participants': []
    }

    assert discord.send_war_nag(config, fake_current_war, []) == True