<s> import json <EOL> from rest_framework . test import APIClient <EOL> from openslides . agenda . models import Item <EOL> from openslides . core . models import CustomSlide <EOL> from openslides . utils . test import TestCase <EOL> class AgendaTreeTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> CustomSlide . objects . create ( title = '<STR_LIT>' ) <EOL> item2 = CustomSlide . objects . create ( title = '<STR_LIT>' ) . agenda_item <EOL> item3 = CustomSlide . objects . create ( title = '<STR_LIT>' ) . agenda_item <EOL> item3 . parent = item2 <EOL> item3 . save ( ) <EOL> self . client = APIClient ( ) <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> def test_get ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( response . content . decode ( ) ) , <EOL> [ { '<STR_LIT>' : [ ] , '<STR_LIT:id>' : <NUM_LIT:1> } , <EOL> { '<STR_LIT>' : [ { '<STR_LIT>' : [ ] , '<STR_LIT:id>' : <NUM_LIT:3> } ] , '<STR_LIT:id>' : <NUM_LIT:2> } ] ) <EOL> def test_set ( self ) : <EOL> tree = [ { '<STR_LIT:id>' : <NUM_LIT:3> } , <EOL> { '<STR_LIT>' : [ { '<STR_LIT:id>' : <NUM_LIT:1> } ] , '<STR_LIT:id>' : <NUM_LIT:2> } ] <EOL> response = self . client . put ( '<STR_LIT>' , { '<STR_LIT>' : tree } , format = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> item1 = Item . objects . get ( pk = <NUM_LIT:1> ) <EOL> item2 = Item . objects . get ( pk = <NUM_LIT:2> ) <EOL> item3 = Item . objects . get ( pk = <NUM_LIT:3> ) <EOL> self . assertEqual ( item1 . parent_id , <NUM_LIT:2> ) <EOL> self . assertEqual ( item1 . weight , <NUM_LIT:0> ) <EOL> self . assertEqual ( item2 . parent_id , None ) <EOL> self . assertEqual ( item2 . weight , <NUM_LIT:1> ) <EOL> self . assertEqual ( item3 . parent_id , None ) <EOL> self . assertEqual ( item3 . weight , <NUM_LIT:0> ) <EOL> def test_set_without_perm ( self ) : <EOL> self . client = APIClient ( ) <EOL> response = self . client . put ( '<STR_LIT>' , { '<STR_LIT>' : [ ] } , format = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_tree_with_double_item ( self ) : <EOL> """<STR_LIT>""" <EOL> tree = [ { '<STR_LIT:id>' : <NUM_LIT:1> } , { '<STR_LIT:id>' : <NUM_LIT:1> } ] <EOL> response = self . client . put ( '<STR_LIT>' , { '<STR_LIT>' : tree } , format = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response . data , { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> def test_tree_with_empty_children ( self ) : <EOL> """<STR_LIT>""" <EOL> tree = [ { '<STR_LIT:id>' : <NUM_LIT:1> } ] <EOL> response = self . client . put ( '<STR_LIT>' , { '<STR_LIT>' : tree } , format = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_tree_with_unknown_item ( self ) : <EOL> """<STR_LIT>""" <EOL> tree = [ { '<STR_LIT:id>' : <NUM_LIT> } ] <EOL> response = self . client . put ( '<STR_LIT>' , { '<STR_LIT>' : tree } , format = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response . data , { '<STR_LIT>' : "<STR_LIT>" } ) <EOL> class TestAgendaPDF ( TestCase ) : <EOL> def test_get ( self ) : <EOL> """<STR_LIT>""" <EOL> CustomSlide . objects . create ( title = '<STR_LIT>' ) <EOL> self . client . login ( username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) </s>
