# -*-*- encoding: utf8 -*-*-

from flask import session
from labmanager.tests.util import G4lTestCase
from labmanager.tests.test_login_admin import BaseTestLogin
from flask.ext.testing import TestCase

msg_error = "it's posible error msg, it has change"
class TestRegisterLabsAdmin(BaseTestLogin, G4lTestCase):
    login_path = '/login/admin/'
    logout_path = '/logout'
    username = 'admin'
    password = 'password'
    usertype = 'labmanager'


    def test_public_availability(self):
        rv = self.login(username=self.username, password=self.password)
        self.assert_200(rv)
        self.assertEquals(self.username, session['loggeduser'])
        rv = self.client.post('/admin/rlms/labs/lab/availability/public',
                              data=dict(lab_id=1, activate=False,
                                        public_identifier="1"),
                              follow_redirects=True)
        self.assert_200(rv)

    def test_public_availability_fail(self):
        rv = self.login(username=self.username, password=self.password)
        self.assert_200(rv)
        self.assertEquals(self.username, session['loggeduser'])
        rv = self.client.post('/admin/rlms/labs/lab/availability/public',
                              data=dict(lab_id=1, activate=False,
                                        public_identifier=""),
                              follow_redirects=True)
        rv = self.client.post('/admin/rlms/labs/lab/availability/public',
                              data=dict(lab_id=2, activate=False,
                                        public_identifier=""),
                              follow_redirects=True)
        self.assert_200(rv)
        try:
            #assert "Public identifier '' already exists" in rv.data
            self.assertIn("Public identifier '' already exists", rv.data)
        except:
            raise msg_error
@@ -195,16 +195,17 @@
 stCase%0A%0A
+%0A
 msg_erro
@@ -213,46 +213,160 @@
  = %22
-it's posible error msg, it has change%22
+Please check the flash error, %5C%0Athis exception can raise if you change it%22%0A%0A%0Aclass ExceptionAssertMsg:%0A    def __str__(self):%0A        return msg_error%0A%0A
 %0Acla
@@ -558,17 +558,16 @@
 nager'%0A%0A
-%0A
     def 
@@ -590,16 +590,21 @@
 lability
+_work
 (self):%0A
@@ -1190,32 +1190,63 @@
 .assert_200(rv)%0A
+        public_identifier = %22%22%0A
         self.ass
@@ -1483,34 +1483,49 @@
 blic_identifier=
-%22%22
+public_identifier
 ),%0A             
@@ -1762,18 +1762,33 @@
 ntifier=
-%22%22
+public_identifier
 ),%0A     
@@ -1888,17 +1888,32 @@
         
-#
+%22%22%22%0A            
 assert %22
@@ -1923,32 +1923,34 @@
 lic identifier '
+%25s
 ' already exists
@@ -1950,16 +1950,38 @@
  exists%22
+ %25 (public_identifier)
  in rv.d
@@ -1984,16 +1984,229 @@
 rv.data%0A
+            print %22Public identifier '%25s' already exists%22 %25 (public_identifier)%0A            I need put this %22 &#39;&#39; %22 to assert identify the content in public_identifier in this case is =%3E %22%22%0A            %22%22%22%0A
         
@@ -2246,10 +2246,18 @@
 ier 
-''
+&#39;&#39;
  alr
@@ -2313,17 +2313,27 @@
   raise 
-msg_error
+ExceptionAssertMsg%0A

change test public availability to correct work