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

Destination Output and Unit Testing #18

Closed
wants to merge 6 commits into from
Closed

Destination Output and Unit Testing #18

wants to merge 6 commits into from

Conversation

davidverweij
Copy link
Owner

Pulled forked repo from @jawrainey into output branch, to collaborate on this in a separate branch. Continues on PR #14

@davidverweij
Copy link
Owner Author

@davidverweij -- I have made the changes you've suggested above and merged master into this PR. Could you test it and let me know your thoughts? Once happy, I can write unit tests for the method (or all methods?!) to put the infrastructure in place for #11, #12 , etc prior to merging this with master. Tests in place will make validating future PR/changes easier -- unless you want to write the tests? 🥇

I will test locally soon and initialize testing infrastructure.

@davidverweij davidverweij linked an issue May 4, 2020 that may be closed by this pull request
@salmannotkhan
Copy link
Contributor

yup i am done with destination folder too

@salmannotkhan
Copy link
Contributor

i was asking what to do if destination folder is not available

@davidverweij
Copy link
Owner Author

@salmannotkhan, could you elaborate on your solution in here please, e.g. code snippets and alike. I haven't seen your code, nor have I tested @jawrainey initial implementation - so I don't have an answer for you yet. Feel free to search and propose a few approaches you think would fix when a destination folder is not available.

@salmannotkhan
Copy link
Contributor

see this is my implementation
docx.write(f"{output}/{file_names[counter] if (custom_name != None) else counter+1}.docx")
i can add verification using os.path library to check whether the directory exists or not
if directory doesn't exist then we can create is using same library

@davidverweij
Copy link
Owner Author

davidverweij commented May 4, 2020

I've successfully ran @jawrainey's implementation from his commits

Testing

Default argument

poetry run convert -t tests/data/example.docx -c tests/data/example.csv

Default argument (folder now exists):

poetry run convert -t tests/data/example.docx -c tests/data/example.csv -p output

Nested folders: (folder does not exist):

poetry run convert -t tests/data/example.docx -c tests/data/example.csv -p how/deep/can/we/go/output

Shortcuts (folder does not exist):

poetry run convert -t tests/data/example.docx -c tests/data/example.csv -p ~/Desktop/output

Relative:

poetry run convert -t tests/data/example.docx -c tests/data/example.csv -p ./output

We should NOT merge this until we have written tests to validate the above and whatever other edge cases we can think of -- hence making this a draft. This is my first time using pathlib, so there may be gotchas I am unaware of, but it seems pretty neat.

Originally posted by @jawrainey in #14 (comment)

Note that the option for an output path is -dest, not -p. I will now start to set up unit testing infrastructure

@salmannotkhan
Copy link
Contributor

so is it final?

@salmannotkhan
Copy link
Contributor

is the ~/ shortcuts are working??

@jawrainey
Copy link
Collaborator

jawrainey commented May 4, 2020

@salmannotkhan -- the implementation is proposed, but @davidverweij suggested that we start writing unit tests (as per the title) so that we can validate our code and reduce the number of bugs introduced in the future.

~/ is a valid shortcut on UNIX for the home directory.

@salmannotkhan
Copy link
Contributor

so is there any bug in this output destination code?

@salmannotkhan
Copy link
Contributor

I'm not familier with unit test writing so

@jawrainey
Copy link
Collaborator

Not that I can find -- can you find any? In short, we can write unit tests to check the above paths automatically, thus validating that our code works. I recommend that you read the following blog post for an overview of testing in python and if you want to learn more there's a good video tutorial on test-driven development.

@davidverweij
Copy link
Owner Author

Just to clarify, is this feature now worked on in #20? If so, perhaps I can close this pull request and continue on #20. Issue #23 can separate out the unit-testing enhancement we want to do.

@jawrainey
Copy link
Collaborator

Yes, but @salmannotkhan made a new PR in #22 ... so we will close #20 once #22 is complete.

So maybe you can continue on #23 once #22 is resolved?

@davidverweij
Copy link
Owner Author

Yes - I meant closing #18, and @salmannotkhan can finish #22.

I will kick off with #23 and rebase once #22 is resolved.

@davidverweij davidverweij added duplicate This issue or pull request already exists wontfix This will not be worked on labels May 6, 2020
@jawrainey jawrainey deleted the output branch May 6, 2020 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add destination folder
3 participants