Commits

Anonymous committed b443cc6

cant create same name room test

Comments (0)

Files changed (3)

src/RoomReservation/reservations/tests.py

         u"""自分で作成した予約を編集できる"""
         reservation = Reservation.objects.create(room=self.room, author=self.user, description=u'詳細です')
         ok_(reservation.can_edit(self.user))
-        x
+        
     def test_cant_edit_other(self):
         u"""他人が作成した予約は編集できない"""
         reservation = Reservation.objects.create(room=self.room, author=self.user, description=u'詳細です')

src/RoomReservation/rooms/models.py

     def get_absolute_url(self):
         return ('rooms-room-detail', (), {
             'pk': self.pk,
-        })
+        })

src/RoomReservation/rooms/tests.py

         list = r.context_data['object_list']
         eq_(list.count(), 1, u"部屋が作成できた")
         self.room = list[0]
-
+        
+    def test_cant_crete_same_name_room(self):
+        u'''管理者ユーザーが同じ名前の部屋を作成できない'''
+        self.room = Room.objects.create(label=u'部屋1', place='どこか', capacity='100')
+        ok_(self.room)
+        c = Client()
+        response = c.post(reverse('auth_login'), {'username': 'miku', 'password': 'mikkumiku'}) 
+        eq_(response.status_code, 302, u'ログインできた')
+        c.post(reverse('rooms-room-create'), {'label' : u'部屋1', 'capacity' : 8, 'place' : 'bbb'})
+        r = c.get(reverse('rooms-room-list'))
+        list = r.context_data['object_list']
+        eq_(list.count(), 1, u"重複する部屋は作成できない")
+        self.room = list[0]
+        
+        
 class TestRoomUpdate(object):
     def setup(self):
         self.user = User.objects.create_user(username="hoge", email='test@test.com',password='hogehoge')