Ejemplo n.º 1
0
 def test_get_nonexistent_character(self):
     print("\nget character that doesn't exist by valid user")
     commands = APICommands()
     result, status_code = commands.get_certain_character(
         "nonexistent_user")
     assert str(status_code) == "200" and str(
         result['result']) == "No such name"
Ejemplo n.º 2
0
 def test_case_del_character_by_invalid_user(self):
     print("\ndelete character that exists by INVALID user and password")
     commands = APICommands()
     error, status_code = commands.delete_character("Vasya0", "some_login",
                                                    "some_password")
     assert str(status_code) == "401" and str(
         error['error']) == "You have to login with proper credentials"
Ejemplo n.º 3
0
 def test_get_all_characters_by_invalid_user(self):
     print("\nget all characters by INVALID user and password")
     commands = APICommands()
     error, status_code = commands.get_all_characters(
         "some_login", "some_password")
     assert str(status_code) == "401" and str(
         error['error']) == "You have to login with proper credentials"
Ejemplo n.º 4
0
 def test_case_del_nonexistent_character(self):
     print("\ndelete nonexistent character")
     commands = APICommands()
     result, status_code = commands.delete_character("Vasya0")
     assert str(status_code) == "200" and "is deleted" in str(
         result["result"])
     result, status_code = commands.delete_character("Vasya0")
     assert str(status_code) == "200" and str(
         result["result"][0]) == "No such name"
Ejemplo n.º 5
0
 def setup_class(self):
     print("\ntest suite setup ")
     commands = APICommands()
     character_dict = APICommands.generate_character(commands,
                                                     character_name="Vasya")
     result, status_code = commands.get_certain_character("Vasya")
     if str(result['result']) == "No such name":
         commands.add_character(character_dict)
     else:
         commands.delete_character("Vasya")
         commands.add_character(character_dict)
Ejemplo n.º 6
0
    def test_get_all_characters_after_deleting(self):
        print("\nget all characters. Actions:")
        print("\n1. del 3 characters if exists")
        print("\n2. get all characters, but check 3(not exist)")
        commands = APICommands()
        commands.del_some_characters("Vasya", 3)
        all_characters, status_code = commands.get_all_characters()
        assert str(status_code) == "200"
        all_characters = all_characters['result']
        i = 0
        for cur_character in all_characters:
            if cur_character["name"] == ("Vasya0" or "Vasya1" or "Vasya2"):
                i += 1

        assert i == 0
Ejemplo n.º 7
0
 def test_get_all_characters(self):
     print("\nget all characters. Actions:")
     print("\n1. add 3 character")
     print("\n2. get all characters, but check 3(exist)")
     print("\n3. del 3 character")
     commands = APICommands()
     all_characters, status_code = commands.get_all_characters()
     assert str(status_code) == "200"
     # todo удалить базу и проверить, что все верные возвращаются
     # сделана проверка хотя бы 3 штуки
     all_characters = all_characters['result']
     i = 0
     for cur_character in all_characters:
         if "Vasya" in cur_character["name"]:
             commands.check_character(cur_character)
             i += 1
     assert i == 3
Ejemplo n.º 8
0
 def test_add_already_exist_character(self):
     print("\nadd character that already exists")
     commands = APICommands()
     character_dict = APICommands.generate_character(commands, character_name="Vasya0")
     commands.add_character(character_dict)
     result, status_code = commands.add_character(character_dict)
     assert str(status_code) == "200" and str((result['result'])) == "Vasya0 is already exists"
Ejemplo n.º 9
0
 def test_add_character(self):
     print("\nadd valid character")
     commands = APICommands()
     character_dict = APICommands.generate_character(commands, character_name="Vasya0")
     result, status_code = commands.add_character(character_dict)
     assert str(status_code) == "200"
     commands.check_character(result['result'])
Ejemplo n.º 10
0
 def test_update_nonexistent_character(self):
     # Does this command create character if not exist? i think so
     print("\nupdate nonexistent character")
     commands = APICommands()
     character_dict = APICommands.generate_character(
         commands, character_name="nonexis")
     result, status_code = commands.update_character(
         "nonexis", character_dict)
     assert str(status_code) == "200"
     commands.check_character(result['result'])
Ejemplo n.º 11
0
 def test_update_character(self):
     print("\nupdate exists character")
     commands = APICommands()
     character_dict = APICommands.generate_character(
         commands, character_name="Vasya0")
     result, status_code = commands.update_character(
         "Vasya0", character_dict)
     # status_code == 500 at 2:20 o'clock 15.05.2019. (system not available or bug ?)
     assert str(status_code) == "200"
     commands.check_character(result['result'])
Ejemplo n.º 12
0
 def teardown(self):
     print("\ntest case teardown")
     # delete 1 character if exists after test case
     commands = APICommands()
     commands.del_some_characters("Vasya", 1)
Ejemplo n.º 13
0
 def setup(self):
     print("\ntest case setup ")
     # add character if not exists
     commands = APICommands()
     commands.add_some_characters("Vasya", 1)
Ejemplo n.º 14
0
 def test_get_certain_character(self):
     print("\nget character that exists by valid user")
     commands = APICommands()
     result, status_code = commands.get_certain_character("Vasya")
     assert str(status_code) == "200"
     commands.check_character(result['result'][0])
Ejemplo n.º 15
0
 def test_add_character_by_invalid_user(self):
     print("\nadd valid character by INVALID user and password")
     commands = APICommands()
     character_dict = APICommands.generate_character(commands, character_name="Vasya0")
     error, status_code = commands.add_character(character_dict, "some_login", "some_password")
     assert str(status_code) == "401" and str(error['error']) == "You have to login with proper credentials"
Ejemplo n.º 16
0
 def test_case_del_character(self):
     print("\ndelete character that exists")
     commands = APICommands()
     result, status_code = commands.delete_character("Vasya0")
     assert str(status_code) == "200" and "is deleted" in str(
         result["result"])
Ejemplo n.º 17
0
 def setup(self):
     print("\ntest case setup ")
     # del 1 character if exists
     commands = APICommands()
     commands.del_some_characters("Vasya", 1)
Ejemplo n.º 18
0
 def teardown_class(self):
     print("\ntest suite teardown")
     commands = APICommands()
     result, status_code = commands.get_certain_character("Vasya")
     if str(result['result']) != "No such name":
         commands.delete_character("Vasya")