# Path: hardware/generate.py
# def generate(model, prefix=_PREFIX):
#     """Generate a list of dict according to a model.
# 
#     Ipv4 ranges are handled by _generate_ip.
#     """
# 
#     # Safe guard for models without ranges
#     for value in model.values():
#         if type(value) != STRING_TYPE:
#             break
#         elif _RANGE_REGEXP.search(value):
#             break
#     else:
#         return [model]
#     # The model has at least one range starting from here
#     result = []
#     yielded = {}
#     yielded.update(model)
#     yielded_copy = yielded.copy()
#     for key, value in yielded_copy.items():
#         if not prefix or key[0] == prefix:
#             if prefix:
#                 yielded[key[1:]] = _generate_values(value, prefix)
#                 del yielded[key]
#             else:
#                 if isinstance(value, str) and not _RANGE_REGEXP.search(value):
#                     yielded[key] = value
#                 else:
#                     yielded[key] = _generate_values(value, prefix)
#         else:
#             yielded[key] = value
#     while True:
#         try:
#             result.append(_call_nexts(yielded))
#         except StopIteration:
#             break
#     return result


from collections import OrderedDict
from hardware import generate
import unittest
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.




class TestGenerate(unittest.TestCase):

    def test_is_included_same(self):
        a = {'a': 1}
        self.assertTrue(generate.is_included(a, a))

    def test_is_included_different(self):
        a = {'a': 1}
        b = {'a': 2}
        self.assertTrue(not generate.is_included(a, b))

    def test_is_included_more(self):
        a = {'a': 1, 'b': 2}
        b = {'a': 1, 'b': 2, 'c': 3}
        self.assertTrue(generate.is_included(a, b))

    def test_generate_ips(self):
        model = '192.168.1.10-12'
        self.assertEqual(list(generate._generate_values(model)),
                         ['192.168.1.10',
                          '192.168.1.11',

# Path: hardware/generate.py
# def generate(model, prefix=_PREFIX):
#     """Generate a list of dict according to a model.
# 
#     Ipv4 ranges are handled by _generate_ip.
#     """
# 
#     # Safe guard for models without ranges
#     for value in model.values():
#         if type(value) != STRING_TYPE:
#             break
#         elif _RANGE_REGEXP.search(value):
#             break
#     else:
#         return [model]
#     # The model has at least one range starting from here
#     result = []
#     yielded = {}
#     yielded.update(model)
#     yielded_copy = yielded.copy()
#     for key, value in yielded_copy.items():
#         if not prefix or key[0] == prefix:
#             if prefix:
#                 yielded[key[1:]] = _generate_values(value, prefix)
#                 del yielded[key]
#             else:
#                 if isinstance(value, str) and not _RANGE_REGEXP.search(value):
#                     yielded[key] = value
#                 else:
#                     yielded[key] = _generate_values(value, prefix)
#         else:
#             yielded[key] = value
#     while True:
#         try:
#             result.append(_call_nexts(yielded))
#         except StopIteration:
#             break
#     return result


# Path: hardware/tests/test_generate.py
from collections import OrderedDict
from hardware import generate
import unittest

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.




class TestGenerate(unittest.TestCase):

    def test_is_included_same(self):
        a = {'a': 1}
        self.assertTrue(generate.is_included(a, a))

    def test_is_included_different(self):
        a = {'a': 1}
        b = {'a': 2}
        self.assertTrue(not generate.is_included(a, b))

    def test_is_included_more(self):
        a = {'a': 1, 'b': 2}
        b = {'a': 1, 'b': 2, 'c': 3}
        self.assertTrue(generate.is_included(a, b))

    def test_generate_ips(self):
        model = '192.168.1.10-12'
        self.assertEqual(list(generate._generate_values(model)),
                         ['192.168.1.10',
                          '192.168.1.11',

                          '192.168.1.12'])