# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2015, Craig Tracey
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    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.

import unittest2 as unittest

from giftwrap.builders import Builder, BUILDER_DRIVER_NAMESPACE
from stevedore import extension


class TestBuilder(unittest.TestCase):

    def test_default_drivers(self):
        drivers = Builder.builder_names()
        self.assertEqual(drivers, ['docker', 'package'])

    def test_additional_drivers(self):
        em = extension.ExtensionManager(BUILDER_DRIVER_NAMESPACE)
        em.extensions.append(extension.Extension('test', None, None, None))
        drivers = Builder.builder_names(em)
        self.assertEqual(drivers, ['docker', 'package', 'test'])

@@ -667,16 +667,28 @@
 cense.%0A%0A
+import copy%0A
 import u
@@ -708,16 +708,16 @@
 nittest%0A
-
 %0Afrom gi
@@ -806,16 +806,59 @@
 ension%0A%0A
+BASE_DRIVERS = set(%5B'docker', 'package'%5D)%0A%0A
 %0Aclass T
@@ -935,32 +935,36 @@
       drivers = 
+set(
 Builder.builder_
@@ -970,16 +970,17 @@
 _names()
+)
 %0A       
@@ -1006,37 +1006,28 @@
 rivers, 
-%5B'docker', 'package'%5D
+BASE_DRIVERS
 )%0A%0A    d
@@ -1220,16 +1220,20 @@
 ivers = 
+set(
 Builder.
@@ -1249,16 +1249,97 @@
 ames(em)
+)%0A        base_drivers = copy.copy(BASE_DRIVERS)%0A        base_drivers.add('test')
 %0A       
@@ -1369,35 +1369,18 @@
 rs, 
-%5B'docker', 'package', 'test'%5D
+base_drivers
 )%0A

Update test_builders to make test more resilient