Browse Source

First real test

master
Raphael Roberts 5 years ago
parent
commit
56b3e02744
  1. 1
      .gitignore
  2. 21
      test_data/property_files/example-new.json
  3. 65
      test_data/property_files/example-old.json
  4. 0
      test_data/property_files/example-old.txt
  5. 45
      tests/test_parser_on_data.py

1
.gitignore

@ -1,2 +1,3 @@
/.dir-locals.el
*.egg-info/
*.pyc

21
test_data/property_files/example-new.json
File diff suppressed because it is too large
View File

65
test_data/property_files/example-old.json
File diff suppressed because it is too large
View File

test_data/property_files/org.qpython.qpy3-20171101-073811.properties → test_data/property_files/example-old.txt

45
tests/test_parser_on_data.py

@ -1,5 +1,50 @@
import os
import json
import pytest
import _pytest
from tibi_hardlinks.backup_parser import parse_property_text
# random_data fixture
# sample data fixture
TEST_PROPERTY_DATA_ROOT = "test_data/property_files"
@pytest.fixture
def canned_data_input(pytestconfig: _pytest.config.Config):
# def canned_data_input():
def get_canned_data(filename):
full_path = os.path.join(
pytestconfig.rootdir, TEST_PROPERTY_DATA_ROOT, filename
)
with open(full_path + ".txt", "r") as test_file:
return test_file.read()
return get_canned_data
@pytest.fixture
def canned_data_output(pytestconfig: _pytest.config.Config):
# def canned_data_output():
def get_canned_data(filename):
full_path = os.path.join(
pytestconfig.rootdir, TEST_PROPERTY_DATA_ROOT, filename
)
with open(full_path + ".json", "r") as test_file:
return json.load(test_file)
return get_canned_data
@pytest.mark.parametrize("filename", [("example-new"), ("example-old")])
def test_canned_data(filename, canned_data_input, canned_data_output):
data = canned_data_input(filename)
expected_output = canned_data_output(filename)
experimental = parse_property_text(data)
for key, value in expected_output.items():
assert experimental[key] == value
Loading…
Cancel
Save