#/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2011-2013, Nigel Small
#
# 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.


from py2neo import neo4j, node


def test_can_set_labels_on_node():
    graph_db = neo4j.GraphDatabaseService()
    if not graph_db.supports_node_labels:
        return
    alice, = graph_db.create(node(name="Alice"))
    alice.add_labels("human", "female")
    labels = alice.get_labels()
    assert len(labels) == 2
    assert labels == set(["human", "female"])
    alice.set_labels("mystery", "badger")
    labels = alice.get_labels()
    assert labels == set(["mystery", "badger"])
    assert labels != set(["human", "female"])
