Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest_load #199

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

unittest_load #199

wants to merge 11 commits into from

Conversation

Real3Lee
Copy link

Unit Test For Load

Load Unit Test

class TestExtractHTMLOp(unittest.TestCase):
def test_extract_html_op_with_url(self):
extract_op = ExtractHTMLOp("test_extract")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we init the function in the class?
e.g. self.extract_op = ExtractHTMLOp("test_splitter")

return_value="<html><body><p>Hello World</p></body></html>",
):
output = extract_op([node])
self.assertEqual(len(output), 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add a new line here?

def test_call_with_empty_node(self, mock_read_file):
        # arrange
        nodes = []

        # act
        output_nodes = self.extract_txt_op(nodes)

        # assert
        mock_read_file.assert_not_called()
        self.assertEqual(len(output_nodes), 0)

self.assertEqual(output[0].value_dict["text"], "Hello World")

def test_extract_html_op_with_filename(self):
extract_op = ExtractHTMLOp("test_extract")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same above

output = extract_op([node])
self.assertEqual(len(output), 1)
self.assertEqual(output[0].value_dict["text"], "")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it might be worth adding two more unit tests to test with more than one node and no node. https://medium.com/@samarthgvasist/parameterized-unit-testing-in-python-9be82fa7e17f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants