Skip to content

Commit

Permalink
added tests to linting
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Oct 9, 2024
1 parent a6846d9 commit ce15c42
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
4 changes: 3 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ exclude = [
"node_modules",
"site-packages",
"venv",
"tests/*",
]

# Same as Black.
Expand All @@ -47,6 +46,9 @@ unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.extend-per-file-ignores]
"tests/*" = ["F401", "F811"]

[format]
# Like Black, use double quotes for strings.
quote-style = "double"
Expand Down
31 changes: 22 additions & 9 deletions tests/test_entity_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def test_create_delete_with_duplicated_names(
subfolder_name,
num_of_subfolders
):
"""Creates two folders with duplicated names
"""Creates two folders with duplicated names
and delete one of them before commit.
Exception should not be raised.
"""
Expand All @@ -499,7 +499,7 @@ def test_create_delete_with_duplicated_names(
for folder_number in range(num_of_subfolders):
subfolder = e.add_new_folder(
"Folder",
parent_id=folder1["id"],
parent_id=folder1["id"],
name=f"{subfolder_name}{folder_number:03}"
)
subfolders.append(subfolder)
Expand All @@ -508,7 +508,7 @@ def test_create_delete_with_duplicated_names(
# create and delete folder with same name
subfolder = e.add_new_folder(
"Folder",
parent_id=folder1["id"],
parent_id=folder1["id"],
name=f"{subfolder_name}{folder_number:03}"
)
e.delete_entity(subfolder)
Expand Down Expand Up @@ -565,7 +565,8 @@ def test_create_delete_with_duplicated_names(
#
# # raises an exception (duplicated names)
# """
# # switch the parent folders - duplicated names exception shouldn't be raised
# # switch the parent folders
# # - duplicated names exception shouldn't be raised
# e.set_entity_parent(subfolders[0]["id"], folders[1]["id"])
# e.set_entity_parent(subfolders[1]["id"], folders[0]["id"])
#
Expand Down Expand Up @@ -598,7 +599,10 @@ def test_create_delete_with_duplicated_names(
#
#
# @pytest.mark.parametrize(
# "parent_folder_name, folder_name, subfolder_name, num_of_folders, num_of_subfolders",
# (
# "parent_folder_name, folder_name, subfolder_name,"
# " num_of_folders, num_of_subfolders"
# ),
# [
# ("entity_hub_test", "folder", "subfolder", 2, 3),
# ]
Expand Down Expand Up @@ -648,7 +652,9 @@ def test_create_delete_with_duplicated_names(
# # move all subfolders from one folder to the next one
# for index, subfolder_id in enumerate(subfolder_ids):
# # next folder (for last folder -> first folder)
# new_parent_id = folder_ids[(index // num_of_subfolders + 1) % num_of_folders]
# new_parent_id = folder_ids[
# (index // num_of_subfolders + 1) % num_of_folders
# ]
#
# # test for me, if new_parent_id is generated correctly
# subfolder = e.get_folder_by_id(subfolder_id)
Expand All @@ -673,9 +679,16 @@ def test_create_delete_with_duplicated_names(
# assert get_folders(
# PROJECT_NAME,
# folder_ids=subfolder_id,
# parent_ids=folder_ids[(index // num_of_subfolders + 1) % num_of_folders]) is not None
# # assert subfolder_id not in my_get_folder_ids(folder_ids[i // num_of_subfolders])
# # assert subfolder_id in my_get_folder_ids(folder_ids[(i // num_of_subfolders + 1) % num_of_folders])
# parent_ids=folder_ids[
# (index // num_of_subfolders + 1) % num_of_folders
# ]
# ) is not None
# # assert subfolder_id not in my_get_folder_ids(
# # folder_ids[i // num_of_subfolders]
# # )
# # assert subfolder_id in my_get_folder_ids(
# # folder_ids[(i // num_of_subfolders + 1) % num_of_folders]
# # )
# """
#
# # e.delete_entity(parent_folder)
Expand Down
16 changes: 11 additions & 5 deletions tests/test_folder_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Make sure you have set AYON_TOKEN in your environment.
"""

import os
import pytest

from ayon_api.operations import (
Expand Down Expand Up @@ -190,7 +189,10 @@ def test_product_duplicated_names(


@pytest.mark.parametrize(
"folder_name, product_name, version_name, representation_name, num_of_versions, num_of_representations",
(
"folder_name, product_name, version_name, representation_name,"
" num_of_versions, num_of_representations"
),
[
("whole_hierarchy", "modelMain", "version", "representation", 2, 3)
]
Expand Down Expand Up @@ -387,7 +389,10 @@ def test_delete_folder_with_product(


@pytest.mark.parametrize(
"folder_name, subfolder_name1, subfolder_name2, count_level1, count_level2",
(
"folder_name, subfolder_name1, subfolder_name2,"
" count_level1, count_level2"
),
[
("folder_with_subfolders1", "subfolder", "shot", 2, 3),
("folder_with_subfolders2", "subfolder", "shot", 3, 4),
Expand All @@ -402,8 +407,9 @@ def test_subfolder_hierarchy(
count_level2
):
"""Creates three levels of folder hierarchy and product in the last one.
Tries creating products with duplicated names and checks raising exceptions.
After creation of every product is checked if the product was really created.
Tries creating products with duplicated names and checks raising
exceptions. After creation of every product is checked if the product
was really created.
"""
project_name = project_entity_fixture["name"]
s = OperationsSession()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_simple_duplicate_add_variable_exception(

def test_exception_empty_query(empty_query):
with pytest.raises(ValueError, match="Missing fields to query"):
out = empty_query.calculate_query()
_out = empty_query.calculate_query()


def test_simple_project_query():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests of server API.
To run use: pytest --envfile {environment path}.
Make sure you have set AYON_TOKEN in your environment.
Make sure you have set AYON_TOKEN in your environment.
"""

import os
Expand All @@ -21,7 +21,7 @@


def test_close_connection():
con = get_server_api_connection()
_con = get_server_api_connection()
assert is_connection_created() is True
close_connection()
assert is_connection_created() is False
Expand Down

0 comments on commit ce15c42

Please sign in to comment.