def test__check_file_with_correct_tag(mock_get_tag, mock_validate, mock_get_example): tag = ExampleTag({"name": "Name"}, "") example = Example(name="filename", sdk=SDK_JAVA, filepath="/root/filename.java", code="data", status=STATUS_UNSPECIFIED, tag=Tag("Name", "Description", False, [], '--option option')) examples = [] mock_get_tag.return_value = tag mock_validate.return_value = True mock_get_example.return_value = example result = _check_file(examples, "filename.java", "/root/filename.java", [], sdk=SDK_JAVA) assert result is False assert len(examples) == 1 assert examples[0] == example mock_get_tag.assert_called_once_with("/root/filename.java") mock_validate.assert_called_once_with(tag.tag_as_dict, []) mock_get_example.assert_called_once_with("/root/filename.java", "filename.java", tag)
def test__check_file_with_correct_tag( mock_get_tag, mock_validate, mock_get_example): tag = {"name": "Name"} example = Example( "filename", "", SDK_UNSPECIFIED, "/root/filename.java", "data", "", STATUS_UNSPECIFIED, Tag("Name", "Description", False, [], '--option option')) examples = [] mock_get_tag.return_value = tag mock_validate.return_value = True mock_get_example.return_value = example result = _check_file(examples, "filename.java", "/root/filename.java", []) assert result is False assert len(examples) == 1 assert examples[0] == example mock_get_tag.assert_called_once_with("/root/filename.java") mock_validate.assert_called_once_with(tag, []) mock_get_example.assert_called_once_with( "/root/filename.java", "filename.java", tag)
def test__check_file_with_incorrect_tag(mock_get_tag, mock_validate): tag = {"name": "Name"} examples = [] mock_get_tag.return_value = tag mock_validate.return_value = False result = _check_file(examples, "filename.java", "/root/filename.java", []) assert result is True assert len(examples) == 0 mock_get_tag.assert_called_once_with("/root/filename.java") mock_validate.assert_called_once_with(tag, [])
def test__check_file_with_incorrect_tag(mock_get_tag, mock_validate): tag = ExampleTag({"name": "Name"}, "") examples = [] sdk = SDK_JAVA mock_get_tag.return_value = tag mock_validate.return_value = False result = _check_file(examples, "filename.java", "/root/filename.java", [], sdk) assert result is True assert len(examples) == 0 mock_get_tag.assert_called_once_with("/root/filename.java") mock_validate.assert_called_once_with(tag.tag_as_dict, [])