Exemplo n.º 1
0
 def test_character_name_unique_per_server(self):
     """Characters should have unique names per server."""
     name = "Dusktrike"
     toon = Character(name=name, server=0, player=make_player(), role=1, powerset=2)
     # save() is required for this test, so toon 1 is persistent.
     toon.save()
     self.assertEqual(name, toon.name)
     second_toon = Character(name=name, server=0, player=make_player(), role=0, powerset=1)
     with self.assertRaises(IntegrityError) as err:
         second_toon.save()
     expected_message = "columns server, name are not unique"
     self.assertEqual(expected_message, err.exception.message)
Exemplo n.º 2
0
 def test_character_negative_votes_starting_count(self):
     """Each Character starst with 0 negative votes from CharacterVote."""
     player = make_player()
     toon = Character(
         name='CMainToon', server=0, role=0, powerset=0, player=player)
     toon.save()
     self.assertEqual(0, toon.negative_votes)
Exemplo n.º 3
0
 def test_character_name_allows_space(self):
     """Characters can have names with spaces in them."""
     name = "Captain DjangoHacker"
     player = make_player()
     toon = Character(name=name, server=0, player=player, role=0, powerset=0)
     toon.full_clean()
     self.assertEqual(name, toon.name)
Exemplo n.º 4
0
 def test_character_player_has_characters(self):
     """Players should be able to have multiple characters."""
     player = make_player()
     toon = Character(name="funbar foo", server=0, player=player)
     another_toon = Character(name="flexbar fofo", server=0, player=player)
     expected_toons = [toon, another_toon]
     actual_toons = list(player.characters.all())
     self.assertEqual(expected_toons.sort(), actual_toons.sort())
Exemplo n.º 5
0
 def test_character_role_required(self):
     """You should not be able to create a character without a role."""
     player = make_player()
     toon = Character(name="foobar", player=player)
     with self.assertRaises(ValidationError) as err:
         toon.full_clean()
     expected_message = "This field cannot be null."
     message_list = err.exception.message_dict.get("role")
     self.assertEqual(expected_message, message_list[0])
Exemplo n.º 6
0
 def test_character_name_blank(self):
     """Characters cannot be created with blank names."""
     player = make_player()
     toon = Character(name="", server=0, player=player)
     with self.assertRaises(ValidationError) as err:
         toon.full_clean()
     expected_message = "This field cannot be blank."
     message_list = err.exception.message_dict.get("name")
     self.assertEqual(expected_message, message_list[0])
Exemplo n.º 7
0
 def test_character_name_length(self):
     """Character names cannot be over 75 characters long."""
     name = "thisisareaallylongname" "fhenjnndeukabandnjndehbdehbhdbehbdehbhdbjndejnjdnejndjendj"
     player = make_player()
     toon = Character(name=name, server=0, player=player)
     with self.assertRaises(ValidationError) as err:
         toon.full_clean()
     expected_message = "Ensure this value has at most 75 characters " "(it has 80)."
     message_list = err.exception.message_dict.get("name")
     self.assertEqual(expected_message, message_list[0])
Exemplo n.º 8
0
 def test_character_level_min(self):
     """A Character cannot have a negative level."""
     player = make_player()
     toon = Character(name="UnrealNegativeHero", player=player, server=0)
     toon.level = -1
     with self.assertRaises(ValidationError) as err:
         toon.full_clean()
     expected_message = "Ensure this value is greater than or equal to 0."
     message_list = err.exception.message_dict.get("level")
     self.assertEqual(expected_message, message_list[0])
Exemplo n.º 9
0
 def test_character_level_cap(self):
     """A Character has a max level of 30."""
     player = make_player()
     toon = Character(name="FakeToon", player=player, server=0)
     toon.level = 31
     with self.assertRaises(ValidationError) as err:
         toon.full_clean()
     expected_message = "Ensure this value is less than or equal to 30."
     message_list = err.exception.message_dict.get("level")
     self.assertEqual(expected_message, message_list[0])
Exemplo n.º 10
0
 def test_character_update_description(self):
     """You should be able to update a Character description."""
     player = make_player()
     toon = Character(name="My SuperDude", server=0, player=player)
     description = """
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
         eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
         enim ad minim veniam, quis nostrud exercitation ullamco."""
     toon.description = description
     self.assertEqual(description, toon.description)
Exemplo n.º 11
0
 def test_character_negative_votes_count_updates(self):
     """Each Character's negative_votes updates after new CharacterVote."""
     player = make_player()
     toon = Character(
         name='DMainToon', server=0, role=0, powerset=0, player=player)
     toon.save()
     alt_toon = Character(
         name='BAltToon', server=0, role=1, powerset=1, player=player)
     alt_toon.save()
     vote = CharacterVote(character=alt_toon, voter=toon, vote=0)
     vote.save()
     self.assertEqual(1, alt_toon.negative_votes)
Exemplo n.º 12
0
 def test_mission_has_lfg_requests(self):
     """A Mission should be associated with its LFGRequests."""
     player = make_player()
     toon = Character(
         name='Scarlet Letter', server=0, role=0, powerset=0, player=player)
     toon.save()
     location = Location(name='Someplace')
     location.save()
     mission = Mission(name='FooMissionBar', location=location)
     mission.save()
     lfg = LFGRequest(character=toon, mission=mission)
     lfg.save()
     expected_requests = [lfg]
     actual_requests = list(mission.requests.all())
     self.assertEqual(expected_requests, actual_requests)
Exemplo n.º 13
0
 def test_character_has_lfg_requests(self):
     """A Character should be associated with his/her LFGRequests."""
     player = make_player()
     toon = Character(
         name='Duskstrike', server=0, role=0, powerset=0, player=player)
     toon.save()
     location = Location(name='Somewhere')
     location.save()
     mission = Mission(name='FooMission', location=location)
     mission.save()
     lfg = LFGRequest(character=toon, mission=mission)
     lfg.save()
     expected_requests = [lfg]
     actual_requests = list(toon.requests.all())
     self.assertEqual(expected_requests, actual_requests)
Exemplo n.º 14
0
 def test_character_votes(self):
     """One character can create a positive vote for another."""
     player = make_player()
     toon = Character(
         name='MyMainToon', server=0, role=0, powerset=0, player=player)
     toon.save()
     alt_toon = Character(
         name='MyAltToon', server=0, role=1, powerset=1, player=player)
     alt_toon.save()
     vote = CharacterVote(character=alt_toon, voter=toon, vote=1)
     vote.save()
     # First, confirm expected behavior for the person voted for.
     votes_for = alt_toon.votes_for.all()
     self.assertIn(vote, votes_for)
     self.assertEqual(1, votes_for[0].vote)
     self.assertEqual(alt_toon, votes_for[0].character)
     # Finally, confirm expected behavior for the person who voted.
     votes_by = toon.votes_by.all()
     self.assertIn(vote, votes_by)
     self.assertEqual(1, votes_by[0].vote)
     self.assertEqual(toon, votes_by[0].voter)