def test_for_classifier_in_diamond_generalization(self):
     leaf = Classifier('Leaf')
     middle1 = Classifier('Middle1', generals=[leaf])
     middle2 = Classifier('Middle2', generals=[leaf])
     top = Classifier('Top', generals=[middle1, middle2])
     assert_that(list(all_indirect_generals(top)),
                 equal_to([middle1, middle2, leaf]))
 def test_for_classifier_with_three_generals(self):
     base1 = Classifier('Base')
     base2 = Classifier('Base')
     base3 = Classifier('Base')
     derived = Classifier('Derived', generals=[base1, base2, base3])
     assert_that(list(all_indirect_generals(derived)),
                 equal_to([base1, base2, base3]))
 def test_find_indirect_in_generalization_chain(self):
     first_operation = Operation('f')
     first = Classifier('First', operations=[first_operation])
     second = Classifier('Second', generals=[first])
     operation = Operation('f')
     Classifier('Third', generals=[second], operations=[operation])
     assert_that(find_overridden(operation), equal_to(first_operation))
 def test_dump_and_load_yaml_recursive_classifier_should_succeed(self):
     classifier = Classifier('a')
     classifier.suppliers = [classifier]
     data = (
         "&id001 !Classifier\n"
         "name: a\n"
         "suppliers:\n"
         "- *id001\n"
     )
     assert_that(yaml.dump(classifier), equal_to(data))
     loaded = yaml.load(data)
     assert_that(loaded, equal_to(classifier))
     assert_that(loaded.suppliers, equal_to([loaded]))
 def test_eq_two_recursive_should_succeed(self):
     a1 = Classifier('A')
     a1.properties = [Property(Type(a1), 'a')]
     a2 = Classifier('A')
     a2.properties = [Property(Type(a2), 'a')]
     assert_that(a1, equal_to(a2))
     assert_that(a1.equiv_pattern(a2))
 def test_for_classifier_in_generalization_tree(self):
     leaf1 = Classifier('Leaf1')
     leaf2 = Classifier('Leaf2')
     leaf3 = Classifier('Leaf3')
     leaf4 = Classifier('Leaf4')
     middle1 = Classifier('Middle1', generals=[leaf1, leaf2])
     middle2 = Classifier('Middle2', generals=[leaf3, leaf4])
     top = Classifier('Top', generals=[middle1, middle2])
     assert_that(list(all_indirect_generals(top)),
                 equal_to([middle1, middle2, leaf1, leaf2, leaf3, leaf4]))
 def test_dump_and_load_yaml_classifier_with_operation_should_succeed(self):
     classifier = Classifier('A', operations=[Operation(name='f')])
     data = (
         "&id001 !Classifier\n"
         "name: A\noperations:\n"
         "- !Operation\n"
         "  name: f\n"
         "  owner: *id001\n"
     )
     assert_that(yaml.dump(classifier), equal_to(data))
     loaded = yaml.load(data)
     assert_that(loaded, equal_to(classifier))
     assert_that(loaded.operations[0].owner, equal_to(loaded))
 def test_dump_and_load_yaml_classifier_with_property_should_succeed(self):
     classifier = Classifier('a', properties=[Property(name='a')])
     data = (
         "&id001 !Classifier\n"
         "name: a\n"
         "properties:\n"
         "- !Property\n"
         "  name: a\n"
         "  owner: *id001\n"
     )
     assert_that(yaml.dump(classifier), equal_to(data))
     loaded = yaml.load(data)
     assert_that(loaded, equal_to(classifier))
     assert_that(loaded.properties[0].owner, equal_to(loaded))
 def test_for_classifier_without_generals(self):
     assert_that(list(all_indirect_generals(Classifier('A'))), empty())
 def test_dump_and_load_yaml_classifier_with_name_should_succeed(self):
     data = "!Classifier {name: a}\n"
     classifier = Classifier('a')
     assert_that(yaml.dump(classifier), equal_to(data))
     assert_that(yaml.load(data), equal_to(classifier))
 def test_eq_with_property_should_succeed(self):
     assert_that(
         Classifier('A', properties=[Property(Type(Classifier('B')), 'b')]),
         equal_to(Classifier('A', properties=[
             Property(Type(Classifier('B')), 'b')])))
 def test_eq_empty_should_succeed(self):
     assert_that(Classifier(), not equal_to(Classifier()))
     assert_that(Classifier('A'), equal_to(Classifier('A')))
 def test_equivalent_pattern_should_succeed(self):
     assert_that(Classifier().equiv_pattern(Classifier()))
 def test_for_classifier_with_one_general(self):
     base = Classifier('Base')
     derived = Classifier('Derived', generals=[base])
     assert_that(list(all_indirect_generals(derived)), equal_to([base]))
 def test_find_for_classifier_with_one_general(self):
     base_operation = Operation('f')
     base = Classifier('Base', operations=[base_operation])
     operation = Operation('f')
     Classifier('Derived', operations=[operation], generals=[base])
     assert_that(find_overridden(operation), equal_to(base_operation))
 def test_find_for_classifier_without_generals(self):
     operation = Operation('f')
     Classifier('A', operations=[operation])
     assert_that(find_overridden(operation), equal_to(None))
 def test_for_classifier_in_generalization_chain(self):
     first = Classifier('First')
     second = Classifier('Second', generals=[first])
     third = Classifier('Third', generals=[second])
     assert_that(list(all_indirect_generals(third)),
                 equal_to([second, first]))