Skip to content

Commit

Permalink
Add new method
Browse files Browse the repository at this point in the history
  • Loading branch information
canihavesomecoffee committed Jun 8, 2017
1 parent fd05c48 commit 84a11af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 7 additions & 7 deletions mod_ci/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def kvm_processor(db, kvm_name, platform, repository, delay):
output_node = etree.SubElement(entry, 'output')
output_node.text = regression_test.output_type.value
compare = etree.SubElement(entry, 'compare')
result_files = TestResultFile.query.filter(and_(
last_files = TestResultFile.query.filter(and_(
TestResultFile.test_id == last_commit.id,
TestResultFile.regression_test_id ==
regression_test.id)).subquery()
Expand All @@ -193,17 +193,17 @@ def kvm_processor(db, kvm_name, platform, repository, delay):
ignore='true' if output_file.ignore else 'false',
id=str(output_file.id)
)
lastcommitfile = g.db.query(result_files.c.got).filter(and_(
result_files.c.regression_test_output_id == output_file.id,
result_files.c.got is not None)).first()
last_commit_files = db.query(last_files.c.got).filter(and_(
last_files.c.regression_test_output_id == output_file.id,
last_files.c.got is not None)).first()
correct = etree.SubElement(file_node, 'correct')
# Need a path that is relative to the folder we provide
# inside the CI environment.
if lastcommitfile is None:
if last_commit_files is None:
correct.text = output_file.filename_correct
else:
correct.text = output_file.filename_expected(
lastcommitfile)
correct.text = output_file.create_correct_filename(
last_commit_files)
expected = etree.SubElement(file_node, 'expected')
expected.text = output_file.filename_expected(
regression_test.sample.sha)
Expand Down
7 changes: 5 additions & 2 deletions mod_regression/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ def __repr__(self):

@property
def filename_correct(self):
return "{name}{extension}".format(
name=self.correct, extension=self.correct_extension)
self.create_correct_filename(self.correct)

def filename_expected(self, sample_hash):
return "{sha}{extra}{extension}".format(
sha=sample_hash, extra=self.expected_filename,
extension=self.correct_extension)

def create_correct_filename(self, name):
return "{name}{extension}".format(
name=name, extension=self.correct_extension)

0 comments on commit 84a11af

Please sign in to comment.