Пример #1
0
 def test_add(self):
     """Add a new character to the rooster."""
     char = Character('test', 80, Character.Races.charr, Character.Sex.male,
                      Character.Professions.guardian, {}, None)
     rooster = Rooster(self.ROOSTER)
     rooster.add(char)
     self.assertEqual(len(rooster), 1)
     return
Пример #2
0
 def _demo_rooster(self):
     """Return a rooster with a couple of characters for group testing."""
     rooster = Rooster(self.ROOSTER)
     thorianar = Character('Thorianar', 80,
                           Character.Races.charr,
                           Character.Sex.male,
                           Character.Professions.guardian,
                           {Character.Disciplines.armorsmith: 500,
                            Character.Disciplines.weaponsmith: 415},
                           Character.Orders.durmand_priori)
     buzzkill = Character('Commander Buzzkill', 80,
                          Character.Races.charr,
                          Character.Sex.male,
                          Character.Professions.engineer,
                          {Character.Disciplines.leatherworker: 500,
                           Character.Disciplines.huntsman: 400},
                          Character.Orders.durmand_priori)
     sgt_buzzkill = Character('Sgt Buzzkill', 25,
                              Character.Races.human,
                              Character.Sex.female,
                              Character.Professions.warrior,
                              {},
                              None)
     rooster.add(thorianar)
     rooster.add(buzzkill)
     rooster.add(sgt_buzzkill)
     rooster.save()
     return
Пример #3
0
 def test_add(self):
     """Add a new character to the rooster."""
     char = Character('test', 80,
                      Character.Races.charr,
                      Character.Sex.male,
                      Character.Professions.guardian,
                      {}, None)
     rooster = Rooster(self.ROOSTER)
     rooster.add(char)
     self.assertEqual(len(rooster), 1)
     return
Пример #4
0
    def test_update(self):
        """Update a character information."""
        request = {
            'name': 'the new thorianar',
            'level': 40,
            'race': 'norn',
            'sex': 'female',
            'profession': 'warrior',
            'discipline1': None,
            'discipline2': None,
            'order': None
        }
        response = self.app.put('/api/characters/thorianar', data=request)
        self.assertJSONOk(response)

        # check the rooster file.
        rooster = Rooster(self.ROOSTER)
        for character in rooster.data:
            if character.slug == 'thorianar':
                self.fail('old character still exists')

            if character.slug == 'the_new_thorianar':
                self.assertEqual(character.name, request['name'])
                self.assertEqual(character.level, request['level'])
                self.assertEqual(character.race.name, request['race'])
                self.assertEqual(character.sex.name, request['sex'])
                self.assertEqual(character.profession.name,
                                 request['profession'])
                self.assertEqual(character.order, request['order'])
                return
        self.fail('character was completely removed')
        return
Пример #5
0
    def test_delete_get(self):
        """Delete a character using GET."""
        response = self.app.get('/api/characters/thorianar?method=DELETE')
        self.assertJSONOk(response)

        # check the rooster file
        rooster = Rooster(self.ROOSTER)
        for character in rooster.data:
            if character.slug == 'thorianar':
                self.fail('old character still exists')
        return
Пример #6
0
    def test_save_load(self):
        """Test if saving the rooster actually saves the file."""
        char = Character('test', 80,
                         Character.Races.charr,
                         Character.Sex.male,
                         Character.Professions.guardian,
                         {Character.Disciplines.armorsmith: 500,
                          Character.Disciplines.weaponsmith: 415},
                         Character.Orders.durmand_priori)
        rooster = Rooster(self.ROOSTER)
        rooster.add(char)

        rooster.save()
        self.assertTrue(os.path.isfile(self.ROOSTER))

        # try to load it back
        new_rooster = Rooster(self.ROOSTER)

        self.assertEqual(len(new_rooster), 1)
        self.assertEqual(new_rooster[0].name, 'test')
        return
Пример #7
0
 def _demo_rooster(self):
     """Return a rooster with a couple of characters for group testing."""
     rooster = Rooster(self.ROOSTER)
     thorianar = Character(
         'Thorianar', 80, Character.Races.charr, Character.Sex.male,
         Character.Professions.guardian, {
             Character.Disciplines.armorsmith: 500,
             Character.Disciplines.weaponsmith: 415
         }, Character.Orders.durmand_priori)
     buzzkill = Character(
         'Commander Buzzkill', 80, Character.Races.charr,
         Character.Sex.male, Character.Professions.engineer, {
             Character.Disciplines.leatherworker: 500,
             Character.Disciplines.huntsman: 400
         }, Character.Orders.durmand_priori)
     sgt_buzzkill = Character('Sgt Buzzkill', 25, Character.Races.human,
                              Character.Sex.female,
                              Character.Professions.warrior, {}, None)
     rooster.add(thorianar)
     rooster.add(buzzkill)
     rooster.add(sgt_buzzkill)
     rooster.save()
     return
Пример #8
0
    def test_save_load(self):
        """Test if saving the rooster actually saves the file."""
        char = Character(
            'test', 80, Character.Races.charr, Character.Sex.male,
            Character.Professions.guardian, {
                Character.Disciplines.armorsmith: 500,
                Character.Disciplines.weaponsmith: 415
            }, Character.Orders.durmand_priori)
        rooster = Rooster(self.ROOSTER)
        rooster.add(char)

        rooster.save()
        self.assertTrue(os.path.isfile(self.ROOSTER))

        # try to load it back
        new_rooster = Rooster(self.ROOSTER)

        self.assertEqual(len(new_rooster), 1)
        self.assertEqual(new_rooster[0].name, 'test')
        return
Пример #9
0
    def test_create(self):
        """Create a new character."""
        request = {
            'name': 'new character',
            'level': 70,
            'race': 'norn',
            'sex': 'male',
            'profession': 'engineer',
            'discipline1': None,
            'discipline2': None,
            'order': None
        }
        response = self.app.post('/api/characters/', data=request)
        self.assertJSONOk(response)

        # check the rooster file.
        rooster = Rooster(self.ROOSTER)
        for character in rooster.data:
            if character.slug == 'new_character':
                return

        self.fail('character is not in the list')
        return
Пример #10
0
    def test_update_json(self):
        """Update a character using JSON request."""
        request = {
            'name': 'the new thorianar',
            'level': 40,
            'race': 'norn',
            'sex': 'female',
            'profession': 'warrior',
            'discipline1': 'chef',
            'discipline1_level': 400,
            'discipline2': 'artificer',
            'discipline2_level': 120,
            'order': 'vigil'
        }
        response = self.app.put('/api/characters/thorianar',
                                data=json.dumps(request),
                                content_type='application/json')
        self.assertJSONOk(response)

        # check the rooster file.
        rooster = Rooster(self.ROOSTER)
        for character in rooster.data:
            if character.slug == 'thorianar':
                self.fail('old character still exists')

            if character.slug == 'the_new_thorianar':
                self.assertEqual(character.name, request['name'])
                self.assertEqual(character.level, request['level'])
                self.assertEqual(character.race.name, request['race'])
                self.assertEqual(character.sex.name, request['sex'])
                self.assertEqual(character.profession.name,
                                 request['profession'])
                self.assertEqual(character.order.name, request['order'])
                return
        self.fail('character was completely removed')
        return
Пример #11
0
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from chesttimer.db.rooster import Rooster
from chesttimer.db.rooster import Character

personal = Rooster('./personal.json')

personal.add(Character('Brigadier Buzzkill', level=80,
                       race=Character.Races.charr,
                       sex=Character.Sex.male,
                       profession=Character.Professions.elementalist,
                       disciplines=None,
                       order=None))
personal.add(Character('Warlord Buzzkill', level=4,
                       race=Character.Races.sylvari,
                       sex=Character.Sex.female,
                       profession=Character.Professions.guardian,
                       disciplines=None,
                       order=None))
personal.add(Character('Thorianar', level=80,
                       race=Character.Races.charr,
                       sex=Character.Sex.male,
                       profession=Character.Professions.guardian,
                       disciplines={Character.Disciplines.armorsmith: 500,
                                    Character.Disciplines.weaponsmith: 429},
                       order=Character.Orders.durmand_priori))
personal.add(Character('Commander Buzzkill', level=80,
                       race=Character.Races.charr,
                       sex=Character.Sex.male,
                       profession=Character.Professions.engineer,