def test_pushable_resources(): """ Test that normal resources are preserved but pushable ones are pushed. """ e = ErrorBundle() e.save_resource("nopush", True) e.save_resource("push", True, pushable=True) assert e.get_resource("nopush") assert e.get_resource("push") e.push_state() assert e.get_resource("nopush") assert not e.get_resource("push") e.save_resource("pushed", True, pushable=True) assert e.get_resource("pushed") e.pop_state() assert e.get_resource("nopush") assert e.get_resource("push") assert not e.get_resource("pushed")
def test_pushable_resources(): """ Test that normal resources are preserved but pushable ones are pushed. """ e = ErrorBundle() e.save_resource('nopush', True) e.save_resource('push', True, pushable=True) assert e.get_resource('nopush') assert e.get_resource('push') e.push_state() assert e.get_resource('nopush') assert not e.get_resource('push') e.save_resource('pushed', True, pushable=True) assert e.get_resource('pushed') e.pop_state() assert e.get_resource('nopush') assert e.get_resource('push') assert not e.get_resource('pushed')
def test_states(): """Test that detected type is preserved, even in subpackages.""" # Use the StringIO as an output buffer. bundle = ErrorBundle() # Populate the bundle with some test data. bundle.detected_type = 4 bundle.error((), "error") bundle.warning((), "warning") bundle.notice((), "notice") bundle.save_resource("test", True) # Push a state bundle.push_state("test.xpi") bundle.detected_type = 2 bundle.error((), "nested error") bundle.warning((), "nested warning") bundle.notice((), "nested notice") # Push another state bundle.push_state("test2.xpi") bundle.detected_type = 3 bundle.error((), "super nested error") bundle.warning((), "super nested warning") bundle.notice((), "super nested notice") # Test that nested compatibility messages retain various # properties. bundle.notice("comp", "Compat Test notice", compatibility_type="error", editors_only=True, signing_severity="high") bundle.pop_state() bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Run some basic tests assert output["detected_type"] == "langpack" assert len(output["messages"]) == 10 messages = [ "error", "warning", "notice", "nested error", "nested warning", "nested notice", "super nested error", "super nested warning", "super nested notice", "Compat Test notice", ] for message in output["messages"]: assert message["message"] in messages messages.remove(message["message"]) assert message["message"].endswith(message["type"]) if message["id"] == "comp": assert message["compatibility_type"] == "error" assert message["editors_only"] == True assert message["signing_severity"] == "high" assert not messages assert bundle.get_resource("test")
def test_file_structure(): """ Test the means by which file names and line numbers are stored in errors, warnings, and messages. """ # Use the StringIO as an output buffer. bundle = ErrorBundle(determined=True) # Populate the bundle with some test data. bundle.error((), "error", description="", filename="file1", column=123) bundle.error((), "error", description="", filename="file2") bundle.error((), "error") # Push a state bundle.push_state("foo") bundle.warning((), "warning", description="", filename="file4", column=123) bundle.warning((), "warning", description="", filename="file5") bundle.warning((), "warning") bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Do the same for friendly output output2 = bundle.print_summary(verbose=False) # Do the same for verbose friendly output output3 = bundle.print_summary(verbose=True) # Run some basic tests assert len(output["messages"]) == 6 assert len(output2) < len(output3) print output print "*" * 50 print output2 print "*" * 50 print output3 print "*" * 50 messages = ["file1", "file2", "", ["foo", "file4"], ["foo", "file5"], ["foo", ""]] for message in output["messages"]: print message assert message["file"] in messages messages.remove(message["file"]) if isinstance(message["file"], list): pattern = message["file"][:] pattern.pop() pattern.append("") file_merge = " > ".join(pattern) print file_merge assert output3.count(file_merge) else: assert output3.count(message["file"]) assert not messages
def test_states(): """Test that detected type is preserved, even in subpackages.""" # Use the StringIO as an output buffer. bundle = ErrorBundle() # Populate the bundle with some test data. bundle.detected_type = 4 bundle.error((), 'error') bundle.warning((), 'warning') bundle.notice((), 'notice') bundle.save_resource('test', True) # Push a state bundle.push_state('test.xpi') bundle.detected_type = 2 bundle.error((), 'nested error') bundle.warning((), 'nested warning') bundle.notice((), 'nested notice') # Push another state bundle.push_state('test2.xpi') bundle.detected_type = 3 bundle.error((), 'super nested error') bundle.warning((), 'super nested warning') bundle.notice((), 'super nested notice') # Test that nested compatibility messages retain various # properties. bundle.notice('comp', 'Compat Test notice', compatibility_type='error', editors_only=True, signing_severity='high') bundle.pop_state() bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Run some basic tests assert output['detected_type'] == 'langpack' assert len(output['messages']) == 10 messages = [ 'error', 'warning', 'notice', 'nested error', 'nested warning', 'nested notice', 'super nested error', 'super nested warning', 'super nested notice', 'Compat Test notice' ] for message in output['messages']: assert message['message'] in messages messages.remove(message['message']) assert message['message'].endswith(message['type']) if message['id'] == 'comp': assert message['compatibility_type'] == 'error' assert message['editors_only'] == True assert message['signing_severity'] == 'high' assert not messages assert bundle.get_resource('test')
def test_file_structure(): """ Test the means by which file names and line numbers are stored in errors, warnings, and messages. """ # Use the StringIO as an output buffer. bundle = ErrorBundle(True) # No color since no output # Populate the bundle with some test data. bundle.error((), 'error', description='', filename='file1', column=123) bundle.error((), 'error', description='', filename='file2') bundle.error((), 'error') # Push a state bundle.push_state('foo') bundle.warning((), 'warning', description='', filename='file4', column=123) bundle.warning((), 'warning', description='', filename='file5') bundle.warning((), 'warning') bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Do the same for friendly output output2 = bundle.print_summary(verbose=False) # Do the same for verbose friendly output output3 = bundle.print_summary(verbose=True) # Run some basic tests assert len(output['messages']) == 6 assert len(output2) < len(output3) print output print '*' * 50 print output2 print '*' * 50 print output3 print '*' * 50 messages = [ 'file1', 'file2', '', ['foo', 'file4'], ['foo', 'file5'], ['foo', ''] ] for message in output['messages']: print message assert message['file'] in messages messages.remove(message['file']) if isinstance(message['file'], list): pattern = message['file'][:] pattern.pop() pattern.append('') file_merge = ' > '.join(pattern) print file_merge assert output3.count(file_merge) else: assert output3.count(message['file']) assert not messages
def test_states(): """Test that detected type is preserved, even in subpackages.""" # Use the StringIO as an output buffer. bundle = ErrorBundle() # Populate the bundle with some test data. bundle.detected_type = 4 bundle.error((), 'error') bundle.warning((), 'warning') bundle.notice((), 'notice') bundle.save_resource('test', True) # Push a state bundle.push_state('test.xpi') bundle.detected_type = 2 bundle.error((), 'nested error') bundle.warning((), 'nested warning') bundle.notice((), 'nested notice') # Push another state bundle.push_state('test2.xpi') bundle.detected_type = 3 bundle.error((), 'super nested error') bundle.warning((), 'super nested warning') bundle.notice((), 'super nested notice') # Test that nested compatibility messages retain various # properties. bundle.notice('comp', 'Compat Test notice', compatibility_type='error', editors_only=True, signing_severity='high') bundle.pop_state() bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Run some basic tests assert output['detected_type'] == 'langpack' assert len(output['messages']) == 10 messages = ['error', 'warning', 'notice', 'nested error', 'nested warning', 'nested notice', 'super nested error', 'super nested warning', 'super nested notice', 'Compat Test notice'] for message in output['messages']: assert message['message'] in messages messages.remove(message['message']) assert message['message'].endswith(message['type']) if message['id'] == 'comp': assert message['compatibility_type'] == 'error' assert message['editors_only'] is True assert message['signing_severity'] == 'high' assert not messages assert bundle.get_resource('test')
def test_file_structure(): """ Test the means by which file names and line numbers are stored in errors, warnings, and messages. """ # Use the StringIO as an output buffer. bundle = ErrorBundle(True) # No color since no output # Populate the bundle with some test data. bundle.error((), 'error', description='', filename='file1', column=123) bundle.error((), 'error', description='', filename='file2') bundle.error((), 'error') # Push a state bundle.push_state('foo') bundle.warning((), 'warning', description='', filename='file4', column=123) bundle.warning((), 'warning', description='', filename='file5') bundle.warning((), 'warning') bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Do the same for friendly output output2 = bundle.print_summary(verbose=False) # Do the same for verbose friendly output output3 = bundle.print_summary(verbose=True) # Run some basic tests assert len(output['messages']) == 6 assert len(output2) < len(output3) print output print '*' * 50 print output2 print '*' * 50 print output3 print '*' * 50 messages = ['file1', 'file2', '', ['foo', 'file4'], ['foo', 'file5'], ['foo', '']] for message in output['messages']: print message assert message['file'] in messages messages.remove(message['file']) if isinstance(message['file'], list): pattern = message['file'][:] pattern.pop() pattern.append('') file_merge = ' > '.join(pattern) print file_merge assert output3.count(file_merge) else: assert output3.count(message['file']) assert not messages
def test_states(): """Tests that detected type is preserved, even in subpackages.""" # Use the StringIO as an output buffer. bundle = ErrorBundle() # Populate the bundle with some test data. bundle.set_type(4) bundle.error((), "error") bundle.warning((), "warning") bundle.notice((), "notice") bundle.save_resource("test", True) # Push a state bundle.push_state("test.xpi") bundle.set_type(2) bundle.error((), "nested error") bundle.warning((), "nested warning") bundle.notice((), "nested notice") # Push another state bundle.push_state("test2.xpi") bundle.set_type(3) bundle.error((), "super nested error") bundle.warning((), "super nested warning") bundle.notice((), "super nested notice") bundle.pop_state() bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Run some basic tests assert output["detected_type"] == "langpack" assert len(output["messages"]) == 9 print output messages = ["error", "warning", "notice", "nested error", "nested warning", "nested notice", "super nested error", "super nested warning", "super nested notice"] for message in output["messages"]: print message assert message["message"] in messages messages.remove(message["message"]) assert message["message"].endswith(message["type"]) assert not messages assert bundle.get_resource("test")
def test_states(): """Test that detected type is preserved, even in subpackages.""" # Use the StringIO as an output buffer. bundle = ErrorBundle() # Populate the bundle with some test data. bundle.detected_type = 4 bundle.error((), "error") bundle.warning((), "warning") bundle.notice((), "notice") bundle.save_resource("test", True) # Push a state bundle.push_state("test.xpi") bundle.detected_type = 2 bundle.error((), "nested error") bundle.warning((), "nested warning") bundle.notice((), "nested notice") # Push another state bundle.push_state("test2.xpi") bundle.detected_type = 3 bundle.error((), "super nested error") bundle.warning((), "super nested warning") bundle.notice((), "super nested notice") # Test that nested compatibility messages retain their value bundle.notice("comp", "Compat Test notice", compatibility_type="error") bundle.pop_state() bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Run some basic tests assert output["detected_type"] == "langpack" assert len(output["messages"]) == 10 print output messages = [ "error", "warning", "notice", "nested error", "nested warning", "nested notice", "super nested error", "super nested warning", "super nested notice", "Compat Test notice" ] for message in output["messages"]: print message assert message["message"] in messages messages.remove(message["message"]) assert message["message"].endswith(message["type"]) if message["id"] == "comp": assert message["compatibility_type"] == "error" assert not messages assert bundle.get_resource("test")
def test_file_structure(): """ Test the means by which file names and line numbers are stored in errors, warnings, and messages. """ # Use the StringIO as an output buffer. bundle = ErrorBundle(True) # No color since no output # Populate the bundle with some test data. bundle.error((), "error", description="", filename="file1", column=123) bundle.error((), "error", description="", filename="file2") bundle.error((), "error") # Push a state bundle.push_state("foo") bundle.warning((), "warning", description="", filename="file4", column=123) bundle.warning((), "warning", description="", filename="file5") bundle.warning((), "warning") bundle.pop_state() # Load the JSON output as an object. output = json.loads(bundle.render_json()) # Do the same for friendly output output2 = bundle.print_summary(verbose=False) # Do the same for verbose friendly output output3 = bundle.print_summary(verbose=True) # Run some basic tests assert len(output["messages"]) == 6 assert len(output2) < len(output3) print output print "*" * 50 print output2 print "*" * 50 print output3 print "*" * 50 messages = [ "file1", "file2", "", ["foo", "file4"], ["foo", "file5"], ["foo", ""] ] for message in output["messages"]: print message assert message["file"] in messages messages.remove(message["file"]) if isinstance(message["file"], list): pattern = message["file"][:] pattern.pop() pattern.append("") file_merge = " > ".join(pattern) print file_merge assert output3.count(file_merge) else: assert output3.count(message["file"]) assert not messages