Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions strictdoc/git/git_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,6 @@ def is_clean_branch(self) -> bool:
return False
return result.stdout == ""

def add_file(self, path_to_file: str) -> None:
result = subprocess.run(
["git", "add", path_to_file],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def add_all(self) -> None:
result = subprocess.run(
["git", "add", "."],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def commit(self, message: str) -> None:
result = subprocess.run(
["git", "commit", "-m", message],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def check_revision(self, revision: str) -> str:
assert isinstance(revision, str)
assert len(revision) > 0
Expand All @@ -130,44 +100,6 @@ def check_revision(self, revision: str) -> str:
return result.stdout.strip()
raise LookupError(f"Non-existing revision: {revision}.")

def commit_all(self, message: str) -> None:
result = subprocess.run(
["git", "commit", "-a", "-m", message],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def rebase_from_main(self) -> None:
result = subprocess.run(
["git", "fetch", "origin"],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result
result = subprocess.run(
["git", "rebase", "origin/main"],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def push(self) -> None:
result = subprocess.run(
["git", "push", "origin"],
cwd=self.path_to_git_root,
capture_output=True,
text=True,
check=True,
)
assert result.returncode == 0, result

def hard_reset(self, revision: Optional[str] = None) -> None:
reset_args = ["git", "reset", "--hard"]
if revision is not None:
Expand Down
21 changes: 0 additions & 21 deletions strictdoc/git/project_diff_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,6 @@ def contains_section_md5(self, section_md5: str) -> bool:
def contains_document_md5(self, document_md5: str) -> bool:
return document_md5 in self.document_md5_hashes

def contains_requirement_field(
self, requirement: SDocNode, field_name: str, field_value: str
):
assert isinstance(field_value, str)
other_requirement: Optional[SDocNode] = self.find_requirement(
requirement
)
if other_requirement is None:
return False

if field_name not in other_requirement.ordered_fields_lookup:
return False

other_requirement_fields = other_requirement.ordered_fields_lookup[
field_name
]
for field_ in other_requirement_fields:
if field_.get_text_value() == field_value:
return True
return False

def get_identical_requirement_field(
self, requirement: SDocNode, field_name: str, field_value: str
) -> Optional[SDocNodeField]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[DOCUMENT]
TITLE: Document 1

[TEXT]
STATEMENT: >>>
Hello world!
<<<

[[SECTION]]
TITLE: Section title #2

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[SECTION]]
TITLE: Section title #1

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[SECTION]]
TITLE: Section title #2.1

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[SECTION]]
TITLE: Section title #2.2

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[DOCUMENT]
TITLE: Document 1

[TEXT]
STATEMENT: >>>
Hello world!
<<<

[[SECTION]]
TITLE: Section title #1

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[SECTION]]
TITLE: Section title #2

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[SECTION]]
TITLE: Section title #2.1

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[SECTION]]
TITLE: Section title #2.2

[TEXT]
STATEMENT: >>>
NOT_RELEVANT
<<<

[[/SECTION]]

[[/SECTION]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from tests.end2end.e2e_case import E2ECase
from tests.end2end.end2end_test_setup import End2EndTestSetup
from tests.end2end.helpers.screens.document.screen_document import (
Screen_Document,
)
from tests.end2end.helpers.screens.project_index.screen_project_index import (
Screen_ProjectIndex,
)
from tests.end2end.server import SDocTestServer
from tests.end2end.test_helpers import available_systems


class Test(E2ECase):
"""
FIXME: This drag and drop test does not work reliably on Linux.
"""

@available_systems(["macos", "windows"])
def test(self):
test_setup = End2EndTestSetup(path_to_test_file=__file__)

with SDocTestServer(
input_path=test_setup.path_to_sandbox
) as test_server:
self.open(test_server.get_host_and_port())

screen_project_index = Screen_ProjectIndex(self)

screen_project_index.assert_on_screen()
screen_project_index.assert_contains_document("Document 1")

screen_document: Screen_Document = (
screen_project_index.do_click_on_first_document()
)

screen_document.assert_on_screen_document()
screen_document.assert_header_document_title("Document 1")

screen_document.assert_text("Hello world!")

screen_document.do_drag_first_toc_node_to_the_second()

assert test_setup.compare_sandbox_and_expected_output()
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import tempfile

import pytest

from strictdoc import environment
from strictdoc.backend.sdoc.models.document import SDocDocument
from strictdoc.backend.sdoc.models.node import SDocNode
Expand Down Expand Up @@ -58,3 +60,27 @@ def test_01_ctest():
test_result_node.get_meta_field_value_by_title("TEST_FUNCTION")
== "#GTEST#TestPrtMath.TransitionDistance"
)


def test__90__error_handling__empty_xml():
source_input = ""

project_config: ProjectConfig = ProjectConfig.default_config(
environment=environment
)

with tempfile.NamedTemporaryFile(
mode="w+", delete=True, suffix=".ctest.junit.xml"
) as temp_file:
doc_file: File = File(
0,
temp_file.name,
SDocRelativePath(os.path.basename(temp_file.name)),
)
with pytest.raises(RuntimeError) as exc_info:
_ = JUnitXMLReader.read_from_string(
source_input, doc_file, project_config
)
assert """\
Document is empty, line 1, column 1 (<string>, line 1)\
""" == str(exc_info.value)
Loading