def test_parseData_fails(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] data = ["text"] with self.assertRaises(IncorrectDataFormatException): build_info.parseData(data)
def test_parseData_array_expected(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] data = "Format-Version: 2.0" with self.assertRaises(IncorrectDataFormatException): build_info.parseData(data)
def test_parseData_format_version(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] data = ["Format-Version: 2.0"] build_info.parseData(data) self.assertEqual(build_info.build_info_array, [{ "format-version": "2.0" }])
def test_parseBlock_license(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.line_no = 0 build_info.build_info_array = [{}] data = ["Format-Version: 2.0", "License-Text: line1", " line2"] values = build_info.parseBlock(data) self.assertEqual(values, [{ "format-version": "2.0", "license-text": "line1\nline2" }])
def test_getInfoForFile_no_block_for_file(self): file_path = os.path.abspath(__file__) build_info = BuildInfo(self.buildinfo_file_path) build_info.full_file_name = file_path build_info.build_info_array = [{}] build_info.file_info_array = [{}] data = [ "Format-Version: 2.0", "Files-Pattern: *.txt", "License-Type: protected" ] build_info.parseData(data) build_info.file_info_array = build_info.getInfoForFile() self.assertEquals(build_info.file_info_array, [{}])
def test_parseData_extra_fields(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] data = [ "Format-Version: 2.0", "Files-Pattern: *.txt", "Build-Name: woohoo" ] build_info.parseData(data) self.assertEqual(build_info.build_info_array, [{ "format-version": "2.0", '*.txt': [{ 'build-name': 'woohoo' }] }])
def test_remove_false_positives_real(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] build_info.file_info_array = [{}] data = [ "Format-Version: 2.0", "Files-Pattern: *.txt", "License-Type: protected", "Files-Pattern: *.txt", "License-Type: open" ] build_info.parseData(data) build_info.file_info_array = build_info.getInfoForFile() build_info.remove_false_positives() self.assertEquals(build_info.file_info_array, [{ 'license-type': 'protected' }])
def test_parseData_block_multiple_patterns(self): build_info = BuildInfo(self.buildinfo_file_path) build_info.build_info_array = [{}] data = [ "Format-Version: 2.0", "Files-Pattern: *.txt,*.tgz", "Build-Name: weehee" ] build_info.parseData(data) expected = [{ 'format-version': '2.0', '*.txt': [{ 'build-name': 'weehee' }], '*.tgz': [{ 'build-name': 'weehee' }] }] self.assertEquals(expected, build_info.build_info_array)