Skip to content

Commit 68ef528

Browse files
authored
fix mime type variables (#11)
1 parent 40f01ad commit 68ef528

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

python_testspace_xml/testspace_xml.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, name='unknown', level='info', description=''):
3333
self.name = name
3434
self.level = level
3535
self.description = description
36-
self.mimeType = None
36+
self.mime_type = None
3737
self.file_path = None
3838
self.link_file = False
3939
self.gzip_data = None
@@ -45,7 +45,7 @@ def add_comment(self, name, comment):
4545

4646
def set_file_annotation(self, file_path=None, mime_type='text/plain', string_buffer=None):
4747
self.file_path = file_path
48-
self.mimeType = mime_type
48+
self.mime_type = mime_type
4949
if file_path is not None:
5050
if not os.path.isfile(self.file_path):
5151
self.level = 'error'
@@ -91,7 +91,7 @@ def write_xml(self, parent_element, dom):
9191

9292
if self.gzip_data is not None:
9393
annotation.setAttribute("link_file", "false")
94-
annotation.setAttribute("mime_type", self.mimeType)
94+
annotation.setAttribute("mime_type", self.mime_type)
9595
b64_data = base64.b64encode(self.gzip_data)
9696
b64_data_string = b64_data.decode()
9797
cdata = dom.createCDATASection(b64_data_string)
@@ -157,7 +157,7 @@ def add_file_annotation(self, name, level='info', description='',
157157
def add_string_buffer_annotation(self, name, level='info', description='',
158158
string_buffer=None, mime_type='text/plain'):
159159
fa = Annotation(name, level, description)
160-
fa.set_file_annotation(string_buffer=string_buffer, mime_type='text/plain')
160+
fa.set_file_annotation(string_buffer=string_buffer, mime_type=mime_type)
161161
self.annotations.append(fa)
162162
return fa
163163

@@ -226,7 +226,7 @@ def add_file_annotation(self, name, level='info', description='',
226226
def add_string_buffer_annotation(self, name, level='info', description='',
227227
string_buffer=None, mime_type='text/plain'):
228228
fa = Annotation(name, level, description)
229-
fa.set_file_annotation(string_buffer=string_buffer, mime_type='text/plain')
229+
fa.set_file_annotation(string_buffer=string_buffer, mime_type=mime_type)
230230
self.annotations.append(fa)
231231
return fa
232232

tests/test_testspace_report.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def create_simple_testspace_xml(self):
1414
string_buffer = 'Text content to be displayed in Testspace\n' \
1515
'Additional line of content'
1616

17+
string_buffer_html = '<!DOCTYPE html><html><head><title>Page Title</title></head>' \
18+
'<body><h1>This is a Heading</h1><p>This is a paragraph.</p></body></html>'
19+
1720
test_annotation = testspace_xml.Annotation('annotation with comment')
1821
test_annotation.add_comment("comment", "annotation comment")
1922

@@ -23,6 +26,8 @@ def create_simple_testspace_xml(self):
2326
example_suite.add_link_annotation(path='https://help.testspace.com')
2427
example_suite.add_string_buffer_annotation(
2528
'Suite string annotation as file', string_buffer=string_buffer)
29+
example_suite.add_string_buffer_annotation(
30+
'Suite string annotation as html', string_buffer=string_buffer_html, mime_type='text/html')
2631
example_suite.add_text_annotation(
2732
'Suite Text Annotation', description='This is a string annotation only')
2833
example_suite.add_file_annotation('tests/report_v1.xsd', file_path='tests/report_v1.xsd')
@@ -79,7 +84,7 @@ def test_number_testsuites(self):
7984

8085
def test_number_testsuite_annotations(self):
8186
test_cases = self.testspace_xml_root.xpath("//test_suite/annotation")
82-
assert len(test_cases) is 5
87+
assert len(test_cases) is 6
8388

8489
def test_number_testcases(self):
8590
test_cases = self.testspace_xml_root.xpath("//test_suite/test_case")

0 commit comments

Comments
 (0)