コード例 #1
0
 def setUp(self):
     self.warinfo = WarInfo(
         json.loads(
             open(os.path.join('data', 'inWar_40.json'),
                  'r',
                  encoding='utf8').read()))
     self.op_member = {
         "tag": "#2GCR2YLP8",
         "name": "captain spock",
         "townhallLevel": 9,
         "mapPosition": 18,
         "opponentAttacks": 2,
         "bestOpponentAttack": {
             "attackerTag": "#G0QPL0LQ",
             "defenderTag": "#2GCR2YLP8",
             "stars": 3,
             "destructionPercentage": 100,
             "order": 78
         }
     }
     self.clan_member = {
         "tag": "#9QVR8R29C",
         "name": "VAHID",
         "townhallLevel": 7,
         "mapPosition": 35,
         "opponentAttacks": 2,
         "bestOpponentAttack": {
             "attackerTag": "#P0C92YP99",
             "defenderTag": "#9QVR8R29C",
             "stars": 3,
             "destructionPercentage": 100,
             "order": 3
         }
     }
コード例 #2
0
 def setUp(self):
     warinfo = WarInfo(
         json.loads(
             open(os.path.join('data', 'warEnded_50.json'),
                  'r',
                  encoding='utf8').read()))
     self.stats = WarStats(warinfo)
     self.attack161 = {
         "destructionPercentage": 53,
         "attackerTag": "#9YUVL0CU",
         "order": 161,
         "stars": 2,
         "defenderTag": "#228U8G88L"
     }
     self.attack150 = {
         "destructionPercentage": 100,
         "attackerTag": "#2Q02GYCYV",
         "order": 150,
         "stars": 3,
         "defenderTag": "#2Y0C8YPYU"
     }
コード例 #3
0
class WarInfoTestCase(unittest.TestCase):
    def setUp(self):
        self.warinfo = WarInfo(
            json.loads(
                open(os.path.join('data', 'inWar_40.json'),
                     'r',
                     encoding='utf8').read()))
        self.op_member = {
            "tag": "#2GCR2YLP8",
            "name": "captain spock",
            "townhallLevel": 9,
            "mapPosition": 18,
            "opponentAttacks": 2,
            "bestOpponentAttack": {
                "attackerTag": "#G0QPL0LQ",
                "defenderTag": "#2GCR2YLP8",
                "stars": 3,
                "destructionPercentage": 100,
                "order": 78
            }
        }
        self.clan_member = {
            "tag": "#9QVR8R29C",
            "name": "VAHID",
            "townhallLevel": 7,
            "mapPosition": 35,
            "opponentAttacks": 2,
            "bestOpponentAttack": {
                "attackerTag": "#P0C92YP99",
                "defenderTag": "#9QVR8R29C",
                "stars": 3,
                "destructionPercentage": 100,
                "order": 3
            }
        }

    def test_start_time(self):
        assert self.warinfo.start_time == '20170603T191148.000Z'

    def test_team_size(self):
        assert self.warinfo.team_size == 40

    def test_get_ordered_attacks(self):
        ordered_attacks = self.warinfo.get_ordered_attacks()

        assert len(ordered_attacks) == 126

    def test_player_count(self):
        assert len(self.warinfo.players) == 80

    def test_get_player_attacks(self):
        player = self.warinfo.players['#2GCR2YLP8']

        assert self.warinfo.get_player_attacks(player) == []

    def test_get_player_info(self):
        self.assertRaises(Exception, '#2GCZZZZP8')

    def test_is_not_in_war(self):
        assert not self.warinfo.is_not_in_war()

    def test_is_in_preparation(self):
        assert not self.warinfo.is_in_preparation()

    def test_is_in_war(self):
        assert self.warinfo.is_in_war()

    def test_is_war_over(self):
        assert not self.warinfo.is_war_over()

    def test_is_clan_member(self):
        self.assertFalse(self.warinfo.is_clan_member(self.op_member))
        self.assertTrue(self.warinfo.is_clan_member(self.clan_member))

    def test_is_win(self):
        self.assertTrue(self.warinfo.is_win())

    def test_is_draw(self):
        self.assertFalse(self.warinfo.is_draw())

    def test_create_war_id(self):
        self.assertEqual(self.warinfo.create_war_id(),
                         "#YVL0C8UY#JC0L922Y20170602T201148.000Z")
コード例 #4
0
 def get_warinfo(self):
     return WarInfo(
         json.loads(
             open(os.path.join('data', 'warEnded_50.json'),
                  'r',
                  encoding='utf8').read()))
コード例 #5
0
 def setUp(self):
     self.warinfo = WarInfo(
         json.loads(
             open(os.path.join('data', 'notInWar.json'),
                  'r',
                  encoding='utf8').read()))
コード例 #6
0
 def get_warinfo(self):
     return WarInfo(
         json.loads(
             open(os.path.join('data', 'op_full_destruction.json'),
                  'r',
                  encoding='utf8').read()))