# Path: lbuild/config.py
# class Option:
#     """
#     Option in the configuration file.
#     """
# 
#     def __init__(self, name, value):
#         """
#         Construct a new option.
# 
#         Args:
#             name: Option name. Can be not fully qualified.
#             value: Value of the option.
#         """
#         self.name = name
#         self.value = value
# 
#     def __eq__(self, other):
#         return (self.name == other.name and self.value == other.value)
# 
#     def __lt__(self, other):
#         return self.name < other.name
# 
#     def __repr__(self):
#         return "<Option: {}={}>".format(self.name, self.value)


import os
import sys
import unittest
import lbuild
from lbuild.config import Option
                            "config",
                            filename)

    def _parse_config(self, filename):
        return lbuild.config.Configuration.parse_configuration(self._get_path(filename))

    def test_should_parse_configuration_file(self):
        config = self._parse_config("configfile/project.xml")

        modules = config.selected_modules
        self.assertEqual(4, len(modules))
        self.assertIn("repo1:other", modules)
        self.assertIn(":module1", modules)
        self.assertIn("::submodule3:subsubmodule1", modules)
        self.assertIn("::submodule3", modules)

        self.assertEqual(7, len(config.options))
        self.assertIn(Option(':target', 'hosted'), config.options)
        self.assertIn(Option('repo1:foo', '43'), config.options)

        self.assertIn(Option('repo1:other:foo', '456'), config.options)
        self.assertIn(Option('repo1::bar', '768'), config.options)
        self.assertIn(Option(':other:xyz', 'No'), config.options)
        self.assertIn(Option('::abc', 'Hello World!'), config.options)
        self.assertIn(Option('::submodule3::price', '15'), config.options)

    def test_should_parse_base_configuration(self):
        config = self._parse_config("configfile_inheritance/depth_0.xml")

        self.assertEqual(1, len(config.repositories))

# Path: lbuild/config.py
# class Option:
#     """
#     Option in the configuration file.
#     """
# 
#     def __init__(self, name, value):
#         """
#         Construct a new option.
# 
#         Args:
#             name: Option name. Can be not fully qualified.
#             value: Value of the option.
#         """
#         self.name = name
#         self.value = value
# 
#     def __eq__(self, other):
#         return (self.name == other.name and self.value == other.value)
# 
#     def __lt__(self, other):
#         return self.name < other.name
# 
#     def __repr__(self):
#         return "<Option: {}={}>".format(self.name, self.value)


# Path: test/config_test.py
import os
import sys
import unittest
import lbuild
from lbuild.config import Option

                            "config",
                            filename)

    def _parse_config(self, filename):
        return lbuild.config.Configuration.parse_configuration(self._get_path(filename))

    def test_should_parse_configuration_file(self):
        config = self._parse_config("configfile/project.xml")

        modules = config.selected_modules
        self.assertEqual(4, len(modules))
        self.assertIn("repo1:other", modules)
        self.assertIn(":module1", modules)
        self.assertIn("::submodule3:subsubmodule1", modules)
        self.assertIn("::submodule3", modules)

        self.assertEqual(7, len(config.options))
        self.assertIn(Option(':target', 'hosted'), config.options)
        self.assertIn(Option('repo1:foo', '43'), config.options)

        self.assertIn(Option('repo1:other:foo', '456'), config.options)
        self.assertIn(Option('repo1::bar', '768'), config.options)
        self.assertIn(Option(':other:xyz', 'No'), config.options)
        self.assertIn(Option('::abc', 'Hello World!'), config.options)
        self.assertIn(Option('::submodule3::price', '15'), config.options)

    def test_should_parse_base_configuration(self):
        config = self._parse_config("configfile_inheritance/depth_0.xml")

        self.assertEqual(1, len(config.repositories))

        self.assertIn(os.path.join(config.configpath, "repo3.lb"), config.repositories)