def test_library_eroot_generated():
    lib = library.Library()
    smith = library.Writer()
    lib.writers.append(smith)
    assert smith.eContainer() is lib
    assert smith.eRoot() is lib
    assert library.Library.eClass.eRoot() is library.eClass
def test_library_econtents_generated():
    smith = library.Writer()
    book = library.Book()
    lib = library.Library()
    lib.writers.append(smith)
    lib.books.append(book)
    assert smith in lib.eContents
    assert book in lib.eContents
def test_link_writer2manybooks_generated():
    book1 = library.Book()
    book2 = library.Book()
    smith = library.Writer()
    smith.books.extend([book1, book2])
    assert smith.books and book1 in smith.books and book2 in smith.books
    assert book1.authors
    assert book2.authors
def test_instance_eisset_generated():
    smith = library.Writer()
    assert smith._isset == set()
    smith.name = 'SmithIsMyName'
    assert library.Writer.name in smith._isset
    assert smith.eIsSet(library.Writer.name)
    assert smith.eIsSet('name')
    smith.name = None
    assert library.Writer.name in smith._isset
    assert smith.eIsSet(library.Writer.name)
    assert smith.eIsSet('name')
Beispiel #5
0
def test_notification_static_add():
    smith = lib.Writer()
    b1 = lib.Book()
    o = LastNotification(smith)
    o2 = LastNotification(b1)
    b1.authors.append(smith)
    n1 = o.notification
    n2 = o2.notification
    assert n1.kind is Kind.ADD
    assert n1.new is b1
    assert n1.feature is lib.Writer.books
    assert n2.kind is Kind.ADD
    assert n2.new is smith
    assert n2.feature is lib.Book.authors
def test_instance_urifragment_generated():
    lib = library.Library()
    assert lib.eURIFragment() == '/'
    smith = library.Writer()
    lib.writers.append(smith)
    assert smith.eURIFragment() == '//@writers.0'
def test_link_writer2book_generated():
    book = library.Book()
    smith = library.Writer()
    smith.books.append(book)
    assert smith.books and smith.books[0] is book
    assert book.authors and book.authors[0] is smith
def test_create_writer_generated():
    smith = library.Writer()
    assert smith and isinstance(smith, Ecore.EObject)
    assert smith.name is None
    assert smith.books == []
def test_static_init_single_attribute_bad_type():
    with pytest.raises(BadValueError):
        library.Writer(name=4)
def test_static_init_single_reference():
    smith = library.Writer(name='Smith')
    book = library.Book(title='Python Roxx', pages=10, authors=[smith])
    assert smith in book.authors
    assert book in smith.books
def test_static_init_single_attribute():
    smith = library.Writer(name='Smith')
    assert smith.name == 'Smith'
    assert smith.eIsSet('name')