# Path: wa/framework/exception.py
# class ConfigError(WAError):
#     """Raised when configuration provided is invalid. This error suggests that
#     the user should modify their config and try again."""
# 
# Path: wa/utils/serializer.py
# class yaml(object):
# 
#     @staticmethod
#     def dump(o, wfh, *args, **kwargs):
#         return _yaml.dump(o, wfh, *args, **kwargs)
# 
#     @staticmethod
#     def load(fh, *args, **kwargs):
#         try:
#             return _yaml.load(fh, *args, Loader=_WaYamlLoader, **kwargs)
#         except _yaml.YAMLError as e:
#             lineno = None
#             if hasattr(e, 'problem_mark'):
#                 lineno = e.problem_mark.line  # pylint: disable=no-member
#             message = e.args[0] if (e.args and e.args[0]) else str(e)
#             raise SerializerSyntaxError(message, lineno)
# 
#     loads = load


import os
import sys
from collections import defaultdict
from unittest import TestCase
from nose.tools import assert_equal, assert_in, raises, assert_true
from wa.framework.configuration.execution import ConfigManager
from wa.framework.configuration.parsers import AgendaParser
from wa.framework.exception import ConfigError
from wa.utils.serializer import yaml
from wa.utils.types import reset_all_counters
        from pprint import pprint
        sectioned_agenda = yaml.load(sectioned_agenda_text)
        self.parser.load(self.config, sectioned_agenda, 'test')

        root_node_workload_entries = self.config.jobs_config.root_node.workload_entries
        leaves = list(self.config.jobs_config.root_node.leaves())
        section1_workload_entries = leaves[0].workload_entries
        section2_workload_entries = leaves[0].workload_entries

        assert_equal(root_node_workload_entries[0].config['workload_name'], 'memcpy')
        assert_true(section1_workload_entries[0].config['workload_parameters']['markers_enabled'])
        assert_equal(section2_workload_entries[0].config['workload_name'], 'antutu')

    def test_yaml_anchors(self):
        yaml_anchors_agenda = yaml.load(yaml_anchors_agenda_text)
        self.parser.load(self.config, yaml_anchors_agenda, 'test')

        workload_entries = self.config.jobs_config.root_node.workload_entries
        assert_equal(len(workload_entries), 2)
        assert_equal(workload_entries[0].config['workload_name'], 'dhrystone')
        assert_equal(workload_entries[0].config['workload_parameters']['threads'], 1)
        assert_equal(workload_entries[0].config['workload_parameters']['delay'], 3)
        assert_equal(workload_entries[1].config['workload_name'], 'dhrystone')
        assert_equal(workload_entries[1].config['workload_parameters']['threads'], 4)
        assert_equal(workload_entries[1].config['workload_parameters']['delay'], 3)

    @raises(ConfigError)
    def test_dup_sections(self):
        dup_sectioned_agenda = yaml.load(dup_sectioned_agenda_text)
        self.parser.load(self.config, dup_sectioned_agenda, 'test')


# Path: wa/framework/exception.py
# class ConfigError(WAError):
#     """Raised when configuration provided is invalid. This error suggests that
#     the user should modify their config and try again."""
# 
# Path: wa/utils/serializer.py
# class yaml(object):
# 
#     @staticmethod
#     def dump(o, wfh, *args, **kwargs):
#         return _yaml.dump(o, wfh, *args, **kwargs)
# 
#     @staticmethod
#     def load(fh, *args, **kwargs):
#         try:
#             return _yaml.load(fh, *args, Loader=_WaYamlLoader, **kwargs)
#         except _yaml.YAMLError as e:
#             lineno = None
#             if hasattr(e, 'problem_mark'):
#                 lineno = e.problem_mark.line  # pylint: disable=no-member
#             message = e.args[0] if (e.args and e.args[0]) else str(e)
#             raise SerializerSyntaxError(message, lineno)
# 
#     loads = load


# Path: tests/test_agenda_parser.py
import os
import sys
from collections import defaultdict
from unittest import TestCase
from nose.tools import assert_equal, assert_in, raises, assert_true
from wa.framework.configuration.execution import ConfigManager
from wa.framework.configuration.parsers import AgendaParser
from wa.framework.exception import ConfigError
from wa.utils.serializer import yaml
from wa.utils.types import reset_all_counters
        from pprint import pprint

        sectioned_agenda = yaml.load(sectioned_agenda_text)
        self.parser.load(self.config, sectioned_agenda, 'test')

        root_node_workload_entries = self.config.jobs_config.root_node.workload_entries
        leaves = list(self.config.jobs_config.root_node.leaves())
        section1_workload_entries = leaves[0].workload_entries
        section2_workload_entries = leaves[0].workload_entries

        assert_equal(root_node_workload_entries[0].config['workload_name'], 'memcpy')
        assert_true(section1_workload_entries[0].config['workload_parameters']['markers_enabled'])
        assert_equal(section2_workload_entries[0].config['workload_name'], 'antutu')

    def test_yaml_anchors(self):
        yaml_anchors_agenda = yaml.load(yaml_anchors_agenda_text)
        self.parser.load(self.config, yaml_anchors_agenda, 'test')

        workload_entries = self.config.jobs_config.root_node.workload_entries
        assert_equal(len(workload_entries), 2)
        assert_equal(workload_entries[0].config['workload_name'], 'dhrystone')
        assert_equal(workload_entries[0].config['workload_parameters']['threads'], 1)
        assert_equal(workload_entries[0].config['workload_parameters']['delay'], 3)
        assert_equal(workload_entries[1].config['workload_name'], 'dhrystone')
        assert_equal(workload_entries[1].config['workload_parameters']['threads'], 4)
        assert_equal(workload_entries[1].config['workload_parameters']['delay'], 3)

    @raises(ConfigError)
    def test_dup_sections(self):
        dup_sectioned_agenda = yaml.load(dup_sectioned_agenda_text)
        self.parser.load(self.config, dup_sectioned_agenda, 'test')


    @raises(ConfigError)