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

Pr 4 #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
Empty file added find_xml_file/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions find_xml_file/find_xml_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os


def find_xml_file(folder):

Choose a reason for hiding this comment

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

What about the instance of more than one xml files?

files = os.listdir(folder)
Copy link

Choose a reason for hiding this comment

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

can we try to find a more descriptive variable name like user_files


xml_file = None
Copy link

Choose a reason for hiding this comment

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

This might need to be renamed xml_files if we are going to possibly grab more than one.


for filename in files:

Choose a reason for hiding this comment

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

great use of a for loop!

if filename.endswith(".xml"):
xml_file = filename
break
Copy link

Choose a reason for hiding this comment

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

Would we want to change this for a scenario where there are more than one xml files?

Choose a reason for hiding this comment

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

Great suggestion, Sara!


return xml_file
Copy link

Choose a reason for hiding this comment

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

is there only one xml file anticipated. What if there is more than one.

3 changes: 3 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

pytest
Empty file added tests/__init__.py
Empty file.
Empty file added tests/test_data/example.xml
Empty file.
10 changes: 10 additions & 0 deletions tests/test_find_xml_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from find_xml_file.find_xml_file import find_xml_file

Choose a reason for hiding this comment

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

This naming could be confusing. Can we rename these files?

Choose a reason for hiding this comment

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

What a great suggestion, Dani!

Copy link

Choose a reason for hiding this comment

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

Since there is only one method in file, maybe we can leave this as is OR rename the file where the method lives, so its is not redundant.



def test_no_files_returns_None():
Copy link

Choose a reason for hiding this comment

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

Are we testing for a specific file? It might be helpful to be more descriptive here. "test_no_xml_files_returns_None():"

assert find_xml_file(".") is None


def test_finds_existing_xml_file():
Copy link

Choose a reason for hiding this comment

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

very good work defining a function

Copy link

Choose a reason for hiding this comment

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

Test looks fine

PATH_TO_TEST_XML = "./test/test_data"
assert find_xml_file(PATH_TO_TEST_XML) == "example.xml"