from gi.repository import Gtk

from gaphor import UML
from gaphor.UML.classes import ClassItem
from gaphor.UML.classes.classespropertypages import ClassAttributes


class TestClassPropertyPages:
    def test_attribute_editing(self, case):
        class_item = case.create(ClassItem, UML.Class)
        model = ClassAttributes(class_item, (str, bool, object))
        model.append([None, False, None])
        path = Gtk.TreePath.new_first()
        iter = model.get_iter(path)
        model.update(iter, col=0, value="attr")

        assert model[iter][-1] is class_item.subject.ownedAttribute[0]

@@ -87,16 +87,33 @@
 lassItem
+, EnumerationItem
 %0Afrom ga
@@ -153,24 +153,30 @@
 ages import 
+(%0A    
 ClassAttribu
@@ -182,45 +182,44 @@
 utes
-%0A%0A%0Aclass TestClassPropertyPages:%0A    
+,%0A    ClassEnumerationLiterals,%0A)%0A%0A%0A
 def 
@@ -245,14 +245,8 @@
 ing(
-self, 
 case
@@ -252,20 +252,16 @@
 e):%0A    
- 
-   
 class_it
@@ -299,20 +299,16 @@
 .Class)%0A
-    
     mode
@@ -360,28 +360,24 @@
 bject))%0A    
- 
-   
 model.append
@@ -398,20 +398,16 @@
  None%5D)%0A
-    
     path
@@ -434,20 +434,16 @@
 first()%0A
-    
     iter
@@ -466,20 +466,16 @@
 r(path)%0A
-    
     mode
@@ -511,20 +511,16 @@
 attr%22)%0A%0A
-    
     asse
@@ -578,8 +578,379 @@
 bute%5B0%5D%0A
+%0A%0Adef test_enumeration_editing(case):%0A    enum_item = case.create(EnumerationItem, UML.Enumeration)%0A    model = ClassEnumerationLiterals(enum_item, (str, object))%0A    model.append(%5BNone, None%5D)%0A    path = Gtk.TreePath.new_first()%0A    iter = model.get_iter(path)%0A    model.update(iter, col=0, value=%22enum%22)%0A%0A    assert model%5Biter%5D%5B-1%5D is enum_item.subject.ownedLiteral%5B0%5D%0A

Add test for enumeration editing