-
Notifications
You must be signed in to change notification settings - Fork 9
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
Improve test coverage #123
Conversation
|
||
with logging_context: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section was dedented since our logging_context, inherited from conda-build, is a no-op
@@ -167,29 +166,6 @@ def basename(path): | |||
) | |||
|
|||
|
|||
def extract_cache(path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting archives of the old cache, only needed during development of new-conda-index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestions
Not a fan of the lengthy SQL statements in test_index, would it be cleaner to provide the mappings as parameters to the execute methods?
threads=1, | ||
) | ||
|
||
instructions = Path(__file__).parents[1] / "tests" / "gen_patch_2.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instructions = Path(__file__).parents[1] / "tests" / "gen_patch_2.py" | |
instructions = Path(__file__).parent / "gen_patch_2.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is parents[0]
the same as parent
, we need the second parent[1]
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need the second parent? gen_patch_2.py
is right next to this file in the same directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean.
for row in self.db.execute( | ||
""" | ||
SELECT path, index_json FROM stat JOIN index_json USING (path) | ||
WHERE stat.stage = ? | ||
ORDER BY path | ||
""", | ||
(self.upstream_stage,), | ||
): | ||
path, index_json = row |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for row in self.db.execute( | |
""" | |
SELECT path, index_json FROM stat JOIN index_json USING (path) | |
WHERE stat.stage = ? | |
ORDER BY path | |
""", | |
(self.upstream_stage,), | |
): | |
path, index_json = row | |
for path, index_json in self.db.execute( | |
""" | |
SELECT path, index_json FROM stat JOIN index_json USING (path) | |
WHERE stat.stage = ? | |
ORDER BY path | |
""", | |
(self.upstream_stage,), | |
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left you some little suggestion gifts, but otherwise I'm glad to see this coverage!
@@ -727,29 +732,9 @@ def index_subdir(self, subdir, verbose=False, progress=False): | |||
|
|||
cache = self.cache_for_subdir(subdir) | |||
|
|||
if verbose: | |||
log.info("Building repodata for %s" % subdir_path) | |||
log.debug("Building repodata for %s" % subdir_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.debug("Building repodata for %s" % subdir_path) | |
log.debug("Building repodata for %s", subdir_path) |
@@ -1093,8 +1063,7 @@ def build_run_exports_data(self, subdir, verbose=False, progress=False): | |||
|
|||
cache = self.cache_for_subdir(subdir) | |||
|
|||
if verbose: | |||
log.info("Building run_exports for %s" % subdir_path) | |||
log.debug("Building run_exports for %s" % subdir_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.debug("Building run_exports for %s" % subdir_path) | |
log.debug("Building run_exports for %s", subdir_path) |
@@ -282,7 +258,7 @@ def convert_cache(conn, cache_generator): | |||
}, | |||
) | |||
|
|||
else: | |||
else: # pragma: no cover | |||
log.warn("Unhandled", match.groupdict()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.warn("Unhandled", match.groupdict()) | |
log.warn("Unhandled: %r", match.groupdict()) |
Without the %r
- won't this ignore the second parameter?
@@ -0,0 +1 @@ | |||
{"build": "0", "build_number": 0, "depends": ["python 2.7.*"], "name": "dummy-package", "subdir": "osx-64", "timestamp": 1557771554052, "version": "1.0", "size": 2517, "md5": "fe3ca1adcd2b7799a5eba03cc774725d", "sha256": "c836fbdafcd615bdb4633264bf096ebc6c3c6977de1f9b2bf527ab6fc6415e01"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have to be a single line? If not, it's easier to spot changes to it later as pretty-printed.
{"build": "0", "build_number": 0, "depends": ["python 2.7.*"], "name": "dummy-package", "subdir": "osx-64", "timestamp": 1557771554052, "version": "1.0", "size": 2517, "md5": "fe3ca1adcd2b7799a5eba03cc774725d", "sha256": "c836fbdafcd615bdb4633264bf096ebc6c3c6977de1f9b2bf527ab6fc6415e01"} | |
{ | |
"build": "0", | |
"build_number": 0, | |
"depends": [ | |
"python 2.7.*" | |
], | |
"name": "dummy-package", | |
"subdir": "osx-64", | |
"timestamp": 1557771554052, | |
"version": "1.0", | |
"size": 2517, | |
"md5": "fe3ca1adcd2b7799a5eba03cc774725d", | |
"sha256": "c836fbdafcd615bdb4633264bf096ebc6c3c6977de1f9b2bf527ab6fc6415e01" | |
} |
@@ -0,0 +1 @@ | |||
{"build": "0", "build_number": 0, "depends": ["python 2.7.*"], "name": "dummy-package", "subdir": "osx-64", "timestamp": 1557771563320, "version": "2.0", "size": 2520, "md5": "621277e18c2627643b156a0f3fad3082", "sha256": "8c2642ca7d68523bda51683703c01cdd5a232bb56f80cf947bfac458c35a5df7"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
{"build": "0", "build_number": 0, "depends": ["python 2.7.*"], "name": "dummy-package", "subdir": "osx-64", "timestamp": 1557771563320, "version": "2.0", "size": 2520, "md5": "621277e18c2627643b156a0f3fad3082", "sha256": "8c2642ca7d68523bda51683703c01cdd5a232bb56f80cf947bfac458c35a5df7"} | |
{ | |
"build": "0", | |
"build_number": 0, | |
"depends": [ | |
"python 2.7.*" | |
], | |
"name": "dummy-package", | |
"subdir": "osx-64", | |
"timestamp": 1557771563320, | |
"version": "2.0", | |
"size": 2520, | |
"md5": "621277e18c2627643b156a0f3fad3082", | |
"sha256": "8c2642ca7d68523bda51683703c01cdd5a232bb56f80cf947bfac458c35a5df7" | |
} |
@@ -0,0 +1 @@ | |||
{"package": {"name": "dummy-package", "version": "1.0"}, "build": {"number": 0, "string": "0"}, "requirements": {"run": ["python=2.7"]}, "extra": {"copy_test_source_files": true, "final": true}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"package": {"name": "dummy-package", "version": "1.0"}, "build": {"number": 0, "string": "0"}, "requirements": {"run": ["python=2.7"]}, "extra": {"copy_test_source_files": true, "final": true}} | |
{ | |
"package": { | |
"name": "dummy-package", | |
"version": "1.0" | |
}, | |
"build": { | |
"number": 0, | |
"string": "0" | |
}, | |
"requirements": { | |
"run": [ | |
"python=2.7" | |
] | |
}, | |
"extra": { | |
"copy_test_source_files": true, | |
"final": true | |
} | |
} |
@@ -0,0 +1 @@ | |||
{"package": {"name": "dummy-package", "version": "2.0"}, "build": {"number": 0, "string": "0"}, "requirements": {"run": ["python=2.7"]}, "extra": {"copy_test_source_files": true, "final": true}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"package": {"name": "dummy-package", "version": "2.0"}, "build": {"number": 0, "string": "0"}, "requirements": {"run": ["python=2.7"]}, "extra": {"copy_test_source_files": true, "final": true}} | |
{ | |
"package": { | |
"name": "dummy-package", | |
"version": "2.0" | |
}, | |
"build": { | |
"number": 0, | |
"string": "0" | |
}, | |
"requirements": { | |
"run": [ | |
"python=2.7" | |
] | |
}, | |
"extra": { | |
"copy_test_source_files": true, | |
"final": true | |
} | |
} |
@@ -0,0 +1 @@ | |||
{"dummy-package-1.0-0.tar.bz2": {"mtime": 1672933250, "size": 2517}, "dummy-package-2.0-0.tar.bz2": {"mtime": 1672933250, "size": 2520}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"dummy-package-1.0-0.tar.bz2": {"mtime": 1672933250, "size": 2517}, "dummy-package-2.0-0.tar.bz2": {"mtime": 1672933250, "size": 2520}} | |
{ | |
"dummy-package-1.0-0.tar.bz2": { | |
"mtime": 1672933250, | |
"size": 2517 | |
}, | |
"dummy-package-2.0-0.tar.bz2": { | |
"mtime": 1672933250, | |
"size": 2520 | |
} | |
} |
convert_cache(conn, extract_cache_filesystem(legacy_cache)) | ||
assert conn.execute("SELECT COUNT(*) FROM index_json").fetchone()[0] == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected the context manager to have closed the conn
connection above. Would this also work?
convert_cache(conn, extract_cache_filesystem(legacy_cache)) | |
assert conn.execute("SELECT COUNT(*) FROM index_json").fetchone()[0] == 2 | |
convert_cache(conn, extract_cache_filesystem(legacy_cache)) | |
assert conn.execute("SELECT COUNT(*) FROM index_json").fetchone()[0] == 2 |
conn.execute( | ||
f"""INSERT INTO index_json VALUES('{features_pkg}','{{"build":"h39de5ba_0","build_number":0,"depends":[],"name":"{features_pkg_name}","noarch":"generic","subdir":"noarch","timestamp":1561127261940,"version":"1.0","md5":"ba68433ef44982170d4e2f2f9bf89338","sha256":"33877cbe447e8c7a026fbcb7e299b37208ad4bc70cf8328fb4cf552af01ada76","size":2683,"track_features":["jim"],"features":["jim"]}}');""" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conn.execute( | |
f"""INSERT INTO index_json VALUES('{features_pkg}','{{"build":"h39de5ba_0","build_number":0,"depends":[],"name":"{features_pkg_name}","noarch":"generic","subdir":"noarch","timestamp":1561127261940,"version":"1.0","md5":"ba68433ef44982170d4e2f2f9bf89338","sha256":"33877cbe447e8c7a026fbcb7e299b37208ad4bc70cf8328fb4cf552af01ada76","size":2683,"track_features":["jim"],"features":["jim"]}}');""" | |
) | |
features_pkg_json = json.dumps( | |
{ | |
"build": "h39de5ba_0", | |
"build_number": 0, | |
"depends": [], | |
"name": features_pkg_name, | |
"noarch": "generic", | |
"subdir": "noarch", | |
"timestamp": 1561127261940, | |
"version": "1.0", | |
"md5": "ba68433ef44982170d4e2f2f9bf89338", | |
"sha256": "33877cbe447e8c7a026fbcb7e299b37208ad4bc70cf8328fb4cf552af01ada76", | |
"size": 2683, | |
"track_features": [ | |
"jim" | |
], | |
"features": [ | |
"jim" | |
] | |
} | |
) | |
conn.execute( | |
f"""INSERT INTO index_json VALUES('{features_pkg}',{features_pkg_json});""" | |
) |
Description
Improve test coverage; include refactors found during testing.
So far, (printed in the CI run outputs),