def test_discarding_non_existent_label_is_ignored(self): node = Node("Person", name="Alice") node.discard_label("Employee") assert node.labels() == {"Person"}
def test_can_clear_labels(self): node = Node("Person", "Employee", name="Alice") node.clear_labels() assert node.labels() == set()
def test_removing_non_existent_label_fails(self): node = Node("Person", name="Alice") with self.assertRaises(KeyError): node.remove_label("Employee")
def test_can_discard_label(self): node = Node("Person", "Employee", name="Alice") node.discard_label("Employee") assert node.labels() == {"Person"}
def test_update_labels(self): node = Node("Person", name="Alice") node.update_labels({"Person", "Employee"}) assert node.labels() == {"Person", "Employee"}
def test_add_label_is_idempotent(self): node = Node("Person", name="Alice") node.add_label("Employee") node.add_label("Employee") assert node.labels() == {"Person", "Employee"}
def test_equality(self): other_node = Node("Person", "Employee", name="Alice", age=33) assert alice == other_node
def test_inequality(self): other_node = Node("Person", "Employee", name="Bob", age=44) assert alice != other_node
def test_has_label(self): node = Node("Person", name="Alice") assert node.has_label("Person") assert not node.has_label("Employee")
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from unittest import TestCase from cypy.primitive import PropertySet, PropertyContainer, TraversableGraph, \ Graph, Node, Relationship, Path, Record, RecordList alice = Node("Person", "Employee", name="Alice", age=33) bob = Node("Person") carol = Node("Person") dave = Node("Person") alice_knows_bob = Relationship(alice, "KNOWS", bob, since=1999) alice_likes_carol = Relationship(alice, "LIKES", carol) carol_dislikes_bob = Relationship(carol, "DISLIKES", bob) carol_married_to_dave = Relationship(carol, "MARRIED_TO", dave) dave_works_for_dave = Relationship(dave, "WORKS_FOR", dave) record_keys = ["employee_id", "Person"] record_a = Record(record_keys, [1001, alice]) record_b = Record(record_keys, [1002, bob]) record_c = Record(record_keys, [1003, carol]) record_d = Record(record_keys, [1004, dave])