Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Sep 24, 2023
1 parent 35880a4 commit 09e0630
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
12 changes: 12 additions & 0 deletions tests/helpers/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ def test_cache():
assert os.path.exists(paths.get_cache_path("md5sums", "abc.py"))
assert cache.get_cache_file("abc.py") == cache_file
assert cache.get_cache_file("abc.cpp") == CacheFile()

# Test if after changing contest type all cached test results are removed
cache_file.save("abc.cpp")
cache_file.save("abc.py")

cache.check_if_contest_type_changed("default")
assert cache.get_cache_file("abc.py") == cache_file
assert cache.get_cache_file("abc.cpp") == cache_file

cache.check_if_contest_type_changed("oi")
assert cache.get_cache_file("abc.py").tests == {}
assert cache.get_cache_file("abc.cpp").tests == {}
12 changes: 8 additions & 4 deletions tests/version_changes/test_expected_scores_format_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
from tests.fixtures import create_package
from sinol_make.util import make_version_changes
import sinol_make
from tests.version_changes.util import change_version


@pytest.mark.parametrize("create_package", [util.get_simple_package_path()], indirect=True)
def test_version_change(create_package):
orig_version = sinol_make.__version__
sinol_make.__version__ = "1.5.9"

change_version("1.5.9")
with open("config.yml", "r") as config_file:
config = yaml.load(config_file, Loader=yaml.FullLoader)
old_expected_scores = config["sinol_expected_scores"]
Expand All @@ -28,4 +27,9 @@ def test_version_change(create_package):
with open("config.yml", "r") as config_file:
config = yaml.load(config_file, Loader=yaml.FullLoader)
assert config["sinol_expected_scores"] == old_expected_scores
sinol_make.__version__ = orig_version

change_version("1.6.0")
make_version_changes()
with open("config.yml", "r") as config_file:
config = yaml.load(config_file, Loader=yaml.FullLoader)
assert config["sinol_expected_scores"] == old_expected_scores
9 changes: 9 additions & 0 deletions tests/version_changes/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import yaml


def change_version(version):
with open("config.yml", "r") as config_file:
config = yaml.load(config_file, Loader=yaml.FullLoader)
config["sinol_version"] = version
with open("config.yml", "w") as config_file:
yaml.dump(config, config_file)

0 comments on commit 09e0630

Please sign in to comment.