-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from analyst-collective/graph-unit-tests
add a simple set of graph unit tests for models only
- Loading branch information
Showing
11 changed files
with
516 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.5 | ||
FROM python:3.6 | ||
|
||
RUN apt-get update | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import fnmatch | ||
import os | ||
import os.path | ||
|
||
|
||
def find_matching(root_path, | ||
relative_paths_to_search, | ||
file_pattern): | ||
""" | ||
Given an absolute `root_path`, a list of relative paths to that | ||
absolute root path (`relative_paths_to_search`), and a `file_pattern` | ||
like '*.sql', returns information about the files. For example: | ||
> find_matching('/root/path', 'models', '*.sql') | ||
[ { 'absolute_path': '/root/path/models/model_one.sql', | ||
'relative_path': 'models/model_one.sql', | ||
'searched_path': 'models' }, | ||
{ 'absolute_path': '/root/path/models/subdirectory/model_two.sql', | ||
'relative_path': 'models/subdirectory/model_two.sql', | ||
'searched_path': 'models' } ] | ||
""" | ||
matching = [] | ||
|
||
for relative_path_to_search in relative_paths_to_search: | ||
absolute_path_to_search = os.path.join( | ||
root_path, relative_path_to_search) | ||
walk_results = os.walk(absolute_path_to_search) | ||
|
||
for current_path, subdirectories, local_files in walk_results: | ||
for local_file in local_files: | ||
absolute_path = os.path.join(current_path, local_file) | ||
relative_path = os.path.relpath( | ||
absolute_path, absolute_path_to_search) | ||
|
||
if fnmatch.fnmatch(local_file, file_pattern): | ||
matching.append({ | ||
'searched_path': relative_path_to_search, | ||
'absolute_path': absolute_path, | ||
'relative_path': relative_path, | ||
}) | ||
|
||
return matching | ||
|
||
|
||
def load_file_contents(path, strip=True): | ||
with open(path, 'rb') as handle: | ||
to_return = handle.read().decode('utf-8') | ||
|
||
if strip: | ||
to_return = to_return.strip() | ||
|
||
return to_return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
nose>=1.3.7 | ||
nosy>=1.1.2 | ||
mock>=1.3.0 | ||
pep8>=1.6.2 | ||
bumpversion==0.5.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.