def setUp(self, m_etcd_client, m_getenv):
     def get_env(key, default=""):
         if key == "ETCD_AUTHORITY":
             return "127.0.0.2:4002"
         else:
             return default
     m_getenv.side_effect = get_env
     self.etcd_client = Mock(spec=EtcdClient)
     m_etcd_client.return_value = self.etcd_client
     self.datastore = LibnetworkDatastoreClient()
     m_etcd_client.assert_called_once_with(host="127.0.0.2", port=4002,
                                           protocol="http", cert=None,
                                           ca_cert=None)
示例#2
0
#
#     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 unittest

from nose.tools import assert_equal, assert_true, assert_false

from libnetwork.datastore_libnetwork import LibnetworkDatastoreClient

# We test using a real etcd back end.
client = LibnetworkDatastoreClient()

TEST_ENDPOINT_ID = "abcdefg123456"


class TestLibnetworkDatastoreClient(unittest.TestCase):
    def setUp(self):
        client.remove_all_data()

    def test_cnm_endpoint_read_write(self):
        """
        Test reading and writing an CNM endpoint.
        """
        data = {"test": 1, "test2": 2}

        # Endpoint should not exist at first, attempts to read it return None.