How to use assertRegexpMatches method in autotest

Best Python code snippet using autotest_python

test_init.py

Source:test_init.py Github

copy

Full Screen

...18 """Check the function do_setting_activemq_users"""19 initRun = Init.Init()20 initRun.do_setting_activemq_users("user", "password")21 file = open(Init.ACTIVEMQ_HOME +'/conf/users.properties', 'r')22 self.assertRegexpMatches(file.read(), "\s+user=password\s+", "Problem when add user on users.properties")23 file.close()24 def test_do_setting_activemq_credential(self):25 """ Check the function do_setting_activemq_credential """26 initRun = Init.Init()27 initRun.do_setting_activemq_credential("user", "password")28 file = open(Init.ACTIVEMQ_HOME +'/conf/credentials.properties', 'r')29 contend = file.read()30 file.close()31 self.assertRegexpMatches(contend, "activemq\.username=user", "Problem when add user on credentials.properties")32 self.assertRegexpMatches(contend, "activemq\.password=password", "Problem when add user on credentials.properties")33 def test_do_setting_activemq_groups(self):34 """Check the function do_setting_activemq_groups"""35 initRun = Init.Init()36 initRun.do_setting_activemq_groups("groups", "user1,user2")37 file = open(Init.ACTIVEMQ_HOME +'/conf/groups.properties', 'r')38 self.assertRegexpMatches(file.read(), "\s+groups=user1,user2\s+", "Problem when add user to group on groups.properties");39 file.close()40 def test_do_setting_activemq_jmx_access(self):41 """Check the function do_setting_activemq_jmx_access"""42 initRun = Init.Init()43 initRun.do_setting_activemq_jmx_access("read", "user", "password")44 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.password', 'r')45 self.assertRegexpMatches(file.read(), "\s+user password\s+", "Problem when add jmx user");46 file.close()47 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.access', 'r')48 self.assertRegexpMatches(file.read(), "\s+user read\s+", "Problem when add jmx user to role");49 file.close()50 def test_do_setting_activemq_web_access(self):51 """Check the function do_setting_activemq_web_access"""52 initRun = Init.Init()53 initRun.do_setting_activemq_web_access("role", "user", "password")54 file = open(Init.ACTIVEMQ_HOME +'/conf/jetty-realm.properties', 'r')55 self.assertRegexpMatches(file.read(), "\s+user: password, role\s+", "Problem when add user to web console");56 file.close()57 def test_do_setting_activemq_wrapper(self):58 """Check the function do_setting_activemq_wrapper"""59 initRun = Init.Init()60 initRun.do_setting_activemq_wrapper(256, 512)61 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')62 contend = file.read()63 file.close()64 self.assertRegexpMatches(contend, "\s+wrapper.java.initmemory=256\s+", "Problem when add min memory to wrapper");65 self.assertRegexpMatches(contend, "\s+wrapper.java.maxmemory=512\s+", "Problem when add max memory to wrapper");66 def test_do_setting_activemq_log4j(self):67 """Check the function do_setting_activemq_log4j"""68 initRun = Init.Init()69 initRun.do_setting_activemq_log4j("FATAL")70 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')71 contend = file.read()72 file.close()73 self.assertRegexpMatches(contend, "\s+log4j.rootLogger=FATAL, console, logfile\s+", "Problem when set the log level on root logger");74 self.assertRegexpMatches(contend, "\s+log4j.logger.org.apache.activemq.audit=FATAL, audit\s+", "Problem when set the log level on audit logger");75 def test_do_setting_activemq_main(self):76 """Check the function do_setting_activemq_main"""77 initRun = Init.Init()78 initRun.do_setting_activemq_main("myServer", 500, "5 gb", "1 gb", 30, 1000, "topic1;topic2;topic3", "queue1;queue2;queue3", "true", "true")79 file = open(Init.ACTIVEMQ_HOME +'/conf/activemq.xml', 'r')80 contend = file.read()81 file.close()82 self.assertRegexpMatches(contend, "\s+brokerName=\"myServer\"\s+", "Problem when set the server name")83 self.assertRegexpMatches(contend, "<constantPendingMessageLimitStrategy limit=\"500\"/>", "Problem when set the message limit")84 self.assertRegexpMatches(contend, "<storeUsage limit=\"5 gb\"/>", "Problem when set the storage usage")85 self.assertRegexpMatches(contend, "<tempUsage limit=\"1 gb\"/>", "Problem when set the temp usage")86 self.assertRegexpMatches(contend, "<transportConnector .*\?maximumConnections=30.*/>", "Problem when set the max connection on broker")87 self.assertRegexpMatches(contend, "<transportConnector .*wireFormat.maxFrameSize=1000.*/>", "Problem when set the max frame size")88 self.assertRegexpMatches(contend, "<broker schedulerSupport=\"true\"", "Problem when enabled scheduler")89 self.assertRegexpMatches(contend, "<destinations>\s*<topic physicalName=\"topic1\"\s*/>\s*<topic physicalName=\"topic2\"\s*/>\s*<topic physicalName=\"topic3\"\s*/>\s*<queue physicalName=\"queue1\"\s*/>\s*<queue physicalName=\"queue2\"\s*/>\s*<queue physicalName=\"queue3\"\s*/>\s*</destinations>", "Problem with static topic and queue")90 rightManagement = """91<plugins>92 <!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->93 <jaasAuthenticationPlugin configuration="activemq" />94 <authorizationPlugin>95 <map>96 <authorizationMap>97 <authorizationEntries>98 <authorizationEntry queue=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />99 <authorizationEntry topic=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />100 <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins,reads,writes,owners" write="admins,reads,writes,owners" admin="admins,reads,writes,owners"/>101 </authorizationEntries>102 <!-- let's assign roles to temporary destinations. comment this entry if we don't want any roles assigned to temp destinations -->103 <tempDestinationAuthorizationEntry>104 <tempDestinationAuthorizationEntry read="tempDestinationAdmins" write="tempDestinationAdmins" admin="tempDestinationAdmins"/>105 </tempDestinationAuthorizationEntry>106 </authorizationMap>107 </map>108 </authorizationPlugin>109</plugins>\n"""110 self.assertRegexpMatches(contend, re.escape(rightManagement), "Problem with inject right management")111 def test_do_remove_default_account(self):112 """113 Check the function do_remove_default_account114 """115 initRun = Init.Init()116 initRun.do_remove_default_account()117 # We check the default value on users.properties118 file = open(Init.ACTIVEMQ_HOME +'/conf/users.properties', 'r')119 contend = file.read()120 file.close()121 self.assertNotRegexpMatches(contend, "admin=admin", "Problem when remove default value on users.properties")122 # We check the default value on groups.properties123 file = open(Init.ACTIVEMQ_HOME +'/conf/groups.properties', 'r')124 contend = file.read()125 file.close()126 self.assertNotRegexpMatches(contend, "admins=admin", "Problem when remove the default value on groups.properties")127 # We check the default value on jetty-realm.properties128 file = open(Init.ACTIVEMQ_HOME +'/conf/jetty-realm.properties', 'r')129 contend = file.read()130 file.close()131 self.assertNotRegexpMatches(contend, "admin: admin, admin", "Problem when remove the default value on jetty-realm.properties")132 self.assertNotRegexpMatches(contend, "user: user, user", "Problem when remove the default value on jetty-realm.properties")133 # We check the default value on jmx.access and jmx.password134 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.access', 'r')135 contend = file.read()136 file.close()137 self.assertNotRegexpMatches(contend, "admin readwrite", "Problem when remove the default value on jmx.access")138 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.password', 'r')139 contend = file.read()140 file.close()141 self.assertNotRegexpMatches(contend, "admin activemq", "Problem when remove the default value on jmx.password")142 file = open(Init.ACTIVEMQ_HOME +'/conf/credentials.properties', 'r')143 contend = file.read()144 file.close()145 self.assertNotRegexpMatches(contend, "activemq\.username=system", "Problem when remove default user on credentials.properties")146 self.assertNotRegexpMatches(contend, "activemq\.password=manager", "Problem when remove default user on credentials.properties")147 self.assertNotRegexpMatches(contend, "guest\.password=password", "Problem when remove default user on credentials.properties")148 def test_do_init_activemq(self):149 """150 Test the function do_init_activemq151 :return:152 """153 initRun = Init.Init()154 initRun.do_init_activemq()155 # We check the value on init script156 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/activemq', 'r')157 contend = file.read()158 file.close()159 self.assertRegexpMatches(contend, "RUN_AS_USER=activemq", "Problem when init the init script")160 # We check value on wrapper161 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')162 contend = file.read()163 file.close()164 self.assertRegexpMatches(contend, "set.default.ACTIVEMQ_DATA=/data/activemq", "Problem when init the wrapper.conf")165 self.assertRegexpMatches(contend, "wrapper.logfile=/var/log/activemq/wrapper.log", "Problem when init the wrapper.conf")166 self.assertRegexpMatches(contend, "set.default.ACTIVEMQ_CONF=%ACTIVEMQ_BASE%/conf.tmp", "Problem when init the wrapper.conf")167 # We check the value on log4j168 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')169 contend = file.read()170 file.close()171 self.assertRegexpMatches(contend, "/var/log/activemq/", "Problem when init the log4j")172 def test_setting_all(self):173 """174 Check the function setting_all175 """176 initRun = Init.Init()177 initRun.setting_all()178 # We check the default value on users.properties179 file = open(Init.ACTIVEMQ_HOME +'/conf/users.properties', 'r')180 contend = file.read()181 file.close()182 self.assertRegexpMatches(contend, "admin=admin", "Problem with default value on users.properties")183 # We check the default value on groups.properties184 file = open(Init.ACTIVEMQ_HOME +'/conf/groups.properties', 'r')185 contend = file.read()186 file.close()187 self.assertRegexpMatches(contend, "admins=admin", "Problem with default value on groups.properties")188 # We check the default value on jetty-realm.properties189 file = open(Init.ACTIVEMQ_HOME +'/conf/jetty-realm.properties', 'r')190 contend = file.read()191 file.close()192 self.assertRegexpMatches(contend, "admin: admin, admin", "Problem with default value on jetty-realm.properties")193 self.assertRegexpMatches(contend, "user: user, user", "Problem with default value on jetty-realm.properties")194 # We check the default value on jmx.access and jmx.password195 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.access', 'r')196 contend = file.read()197 file.close()198 self.assertRegexpMatches(contend, "admin readwrite", "Problem with default value on jmx.access")199 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.password', 'r')200 contend = file.read()201 file.close()202 self.assertRegexpMatches(contend, "admin activemq", "Problem with default value on jmx.password")203 # We check the default value on log4.properties204 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')205 contend = file.read()206 file.close()207 self.assertRegexpMatches(contend, "log4j\.rootLogger=INFO, console, logfile", "Problem with default value on log4j.properties")208 self.assertRegexpMatches(contend, "log4j\.logger\.org\.apache\.activemq\.audit=INFO, audit", "Problem with default value on log4j.properties")209 # We check the default value on wrapper.conf210 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')211 contend = file.read()212 file.close()213 self.assertRegexpMatches(contend, "wrapper.java.initmemory=128", "Problem with default value on wrapper.conf");214 self.assertRegexpMatches(contend, "wrapper.java.maxmemory=1024", "Problem with default value on wrapper.conf");215 # We check the default value on activemq.xml216 file = open(Init.ACTIVEMQ_HOME +'/conf/activemq.xml', 'r')217 contend = file.read()218 file.close()219 self.assertRegexpMatches(contend, "\s+brokerName=\"localhost\"\s+", "Problem with the default value on activemq.xml")220 self.assertRegexpMatches(contend, "<constantPendingMessageLimitStrategy limit=\"1000\"/>", "Problem with the default value on activemq.xml")221 self.assertRegexpMatches(contend, "<storeUsage limit=\"100 gb\"/>", "Problem with the default value on activemq.xml")222 self.assertRegexpMatches(contend, "<tempUsage limit=\"50 gb\"/>", "Problem with the default value on activemq.xml")223 self.assertRegexpMatches(contend, "<transportConnector .*\?maximumConnections=1000.*/>", "Problem with the default value on activemq.xml")224 self.assertRegexpMatches(contend, "<transportConnector .*wireFormat.maxFrameSize=104857600.*/>", "Problem with the default value on activemq.xml")225 self.assertRegexpMatches(contend, "<broker schedulerSupport=\"true\"", "Problem with the default value on activemq.xml")226 self.assertNotRegexpMatches(contend, "<destinations>.*</destinations>", "Problem with the default value on activemq.xml")227 rightManagement = """228<plugins>229 <!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->230 <jaasAuthenticationPlugin configuration="activemq" />231 <authorizationPlugin>232 <map>233 <authorizationMap>234 <authorizationEntries>235 <authorizationEntry queue=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />236 <authorizationEntry topic=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />237 <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins,reads,writes,owners" write="admins,reads,writes,owners" admin="admins,reads,writes,owners"/>238 </authorizationEntries>239 <!-- let's assign roles to temporary destinations. comment this entry if we don't want any roles assigned to temp destinations -->240 <tempDestinationAuthorizationEntry>241 <tempDestinationAuthorizationEntry read="tempDestinationAdmins" write="tempDestinationAdmins" admin="tempDestinationAdmins"/>242 </tempDestinationAuthorizationEntry>243 </authorizationMap>244 </map>245 </authorizationPlugin>246</plugins>\n"""247 self.assertNotRegexpMatches(contend, re.escape(rightManagement), "Problem with the default value on activemq.xml")248 # We check the value on init script249 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/activemq', 'r')250 contend = file.read()251 file.close()252 self.assertRegexpMatches(contend, "RUN_AS_USER=activemq", "Problem when init the init script")253 # We check value on wrapper254 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')255 contend = file.read()256 file.close()257 self.assertRegexpMatches(contend, "set.default.ACTIVEMQ_DATA=/data/activemq", "Problem when init the wrapper.conf")258 self.assertRegexpMatches(contend, "wrapper.logfile=/var/log/activemq/wrapper.log", "Problem when init the wrapper.conf")259 # We check the value on log4j260 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')261 contend = file.read()262 file.close()263 self.assertRegexpMatches(contend, "/var/log/activemq/", "Problem when init the log4j")264 ########################################################################################265 # We now check all parameters266 os.environ["ACTIVEMQ_NAME"] = "myTest"267 os.environ["ACTIVEMQ_LOGLEVEL"] = "DEBUG"268 os.environ["ACTIVEMQ_PENDING_MESSAGE_LIMIT"] = "2000"269 os.environ["ACTIVEMQ_STORAGE_USAGE"] = "10 gb"270 os.environ["ACTIVEMQ_TEMP_USAGE"] = "5 gb"271 os.environ["ACTIVEMQ_MAX_CONNECTION"] = "10"272 os.environ["ACTIVEMQ_FRAME_SIZE"] = "2000000"273 os.environ["ACTIVEMQ_MIN_MEMORY"] = "256"274 os.environ["ACTIVEMQ_MAX_MEMORY"] = "512"275 os.environ["ACTIVEMQ_ADMIN_LOGIN"] = "admin"276 os.environ["ACTIVEMQ_ADMIN_PASSWORD"] = "P@ssw0rd"277 os.environ["ACTIVEMQ_USER_LOGIN"] = "disaster"278 os.environ["ACTIVEMQ_USER_PASSWORD"] = "pasword1234"279 os.environ["ACTIVEMQ_READ_LOGIN"] = "read"280 os.environ["ACTIVEMQ_READ_PASSWORD"] = "read1234"281 os.environ["ACTIVEMQ_WRITE_LOGIN"] = "write"282 os.environ["ACTIVEMQ_WRITE_PASSWORD"] = "write1234"283 os.environ["ACTIVEMQ_OWNER_LOGIN"] = "owner"284 os.environ["ACTIVEMQ_OWNER_PASSWORD"] = "owner1234"285 os.environ["ACTIVEMQ_JMX_LOGIN"] = "jmx"286 os.environ["ACTIVEMQ_JMX_PASSWORD"] = "jmx1234"287 os.environ["ACTIVEMQ_STATIC_TOPICS"] = "topic1;topic2"288 os.environ["ACTIVEMQ_STATIC_QUEUES"] = "queue1;queue2;queue3"289 os.environ["ACTIVEMQ_REMOVE_DEFAULT_ACCOUNT"] = "true"290 os.environ["ACTIVEMQ_ENABLED_SCHEDULER"] = "true"291 os.environ["ACTIVEMQ_ENABLED_AUTH"] = "true"292 initRun.setting_all()293 # We check the default value on users.properties294 file = open(Init.ACTIVEMQ_HOME +'/conf/users.properties', 'r')295 contend = file.read()296 file.close()297 self.assertRegexpMatches(contend, "admin=P@ssw0rd", "Problem with set value on users.properties")298 self.assertRegexpMatches(contend, "read=read1234", "Problem with set value on users.properties")299 self.assertRegexpMatches(contend, "write=write1234", "Problem with set value on users.properties")300 self.assertRegexpMatches(contend, "owner=owner1234", "Problem with set value on users.properties")301 # We check the default value on groups.properties302 file = open(Init.ACTIVEMQ_HOME +'/conf/groups.properties', 'r')303 contend = file.read()304 file.close()305 self.assertRegexpMatches(contend, "admins=admin", "Problem with set value on groups.properties")306 self.assertRegexpMatches(contend, "reads=read", "Problem with set value on groups.properties")307 self.assertRegexpMatches(contend, "writes=write", "Problem with set value on groups.properties")308 self.assertRegexpMatches(contend, "owners=owner", "Problem with set value on groups.properties")309 # We check the default value on jetty-realm.properties310 file = open(Init.ACTIVEMQ_HOME +'/conf/jetty-realm.properties', 'r')311 contend = file.read()312 file.close()313 self.assertRegexpMatches(contend, "admin: P@ssw0rd, admin", "Problem with default value on jetty-realm.properties")314 self.assertRegexpMatches(contend, "disaster: pasword1234, user", "Problem with default value on jetty-realm.properties")315 # We check the default value on jmx.access and jmx.password316 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.access', 'r')317 contend = file.read()318 file.close()319 self.assertRegexpMatches(contend, "jmx readwrite", "Problem with set value on jmx.access")320 file = open(Init.ACTIVEMQ_HOME +'/conf/jmx.password', 'r')321 contend = file.read()322 file.close()323 self.assertRegexpMatches(contend, "jmx jmx1234", "Problem with set value on jmx.password")324 # We check the default value on log4.properties325 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')326 contend = file.read()327 file.close()328 self.assertRegexpMatches(contend, "log4j\.rootLogger=DEBUG, console, logfile", "Problem with set value on log4j.properties")329 self.assertRegexpMatches(contend, "log4j\.logger\.org\.apache\.activemq\.audit=DEBUG, audit", "Problem with set value on log4j.properties")330 # We check the default value on wrapper.conf331 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')332 contend = file.read()333 file.close()334 self.assertRegexpMatches(contend, "wrapper.java.initmemory=256", "Problem with set value on wrapper.conf");335 self.assertRegexpMatches(contend, "wrapper.java.maxmemory=512", "Problem with set value on wrapper.conf");336 # We check the default value on activemq.xml337 file = open(Init.ACTIVEMQ_HOME +'/conf/activemq.xml', 'r')338 contend = file.read()339 file.close()340 self.assertRegexpMatches(contend, "\s+brokerName=\"myTest\"\s+", "Problem with set the value on activemq.xml")341 self.assertRegexpMatches(contend, "<constantPendingMessageLimitStrategy limit=\"2000\"/>", "Problem with set the value on activemq.xml")342 self.assertRegexpMatches(contend, "<storeUsage limit=\"10 gb\"/>", "Problem with set the value on activemq.xml")343 self.assertRegexpMatches(contend, "<tempUsage limit=\"5 gb\"/>", "Problem with set the value on activemq.xml")344 self.assertRegexpMatches(contend, "<transportConnector .*\?maximumConnections=10.*/>", "Problem with set the value on activemq.xml")345 self.assertRegexpMatches(contend, "<transportConnector .*wireFormat.maxFrameSize=2000000.*/>", "Problem with set the value on activemq.xml")346 self.assertRegexpMatches(contend, "<broker schedulerSupport=\"true\"", "Problem with set the value on activemq.xml")347 self.assertRegexpMatches(contend, "<destinations>\s*<topic physicalName=\"topic1\"\s*/>\s*<topic physicalName=\"topic2\"\s*/>\s*<queue physicalName=\"queue1\"\s*/>\s*<queue physicalName=\"queue2\"\s*/>\s*<queue physicalName=\"queue3\"\s*/>\s*</destinations>", "Problem with set the value on activemq.xml")348 rightManagement = """349<plugins>350 <!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->351 <jaasAuthenticationPlugin configuration="activemq" />352 <authorizationPlugin>353 <map>354 <authorizationMap>355 <authorizationEntries>356 <authorizationEntry queue=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />357 <authorizationEntry topic=">" read="admins,reads,writes,owners" write="admins,writes,owners" admin="admins,owners" />358 <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins,reads,writes,owners" write="admins,reads,writes,owners" admin="admins,reads,writes,owners"/>359 </authorizationEntries>360 <!-- let's assign roles to temporary destinations. comment this entry if we don't want any roles assigned to temp destinations -->361 <tempDestinationAuthorizationEntry>362 <tempDestinationAuthorizationEntry read="tempDestinationAdmins" write="tempDestinationAdmins" admin="tempDestinationAdmins"/>363 </tempDestinationAuthorizationEntry>364 </authorizationMap>365 </map>366 </authorizationPlugin>367</plugins>\n"""368 self.assertRegexpMatches(contend, re.escape(rightManagement), "Problem with set the value on activemq.xml")369 # We check the value on init script370 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/activemq', 'r')371 contend = file.read()372 file.close()373 self.assertRegexpMatches(contend, "RUN_AS_USER=activemq", "Problem when init the init script")374 # We check value on wrapper375 file = open(Init.ACTIVEMQ_HOME +'/bin/linux-x86-64/wrapper.conf', 'r')376 contend = file.read()377 file.close()378 self.assertRegexpMatches(contend, "set.default.ACTIVEMQ_DATA=/data/activemq", "Problem when init the wrapper.conf")379 self.assertRegexpMatches(contend, "wrapper.logfile=/var/log/activemq/wrapper.log", "Problem when init the wrapper.conf")380 # We check the value on log4j381 file = open(Init.ACTIVEMQ_HOME +'/conf/log4j.properties', 'r')382 contend = file.read()383 file.close()384 self.assertRegexpMatches(contend, "/var/log/activemq/", "Problem when init the log4j")385if __name__ == '__main__':...

Full Screen

Full Screen

testoatbran.py

Source:testoatbran.py Github

copy

Full Screen

...6class TestOatBran(TestCase):7 def test_brackets(self):8 L_BRACKET = '['9 R_BRACKET = "]"10 self.assertRegexpMatches(L_BRACKET, bran.L_BRACKET)11 self.assertNotRegexpMatches(R_BRACKET, bran.L_BRACKET)12 self.assertRegexpMatches(R_BRACKET, bran.R_BRACKET)13 self.assertNotRegexpMatches(L_BRACKET, bran.R_BRACKET)14 return15 def test_spaces(self):16 space = ' '17 empty_string = ''18 spaces = ' '19 self.assertRegexpMatches(space, bran.SPACE)20 self.assertNotRegexpMatches(empty_string, bran.SPACE)21 self.assertNotRegexpMatches(COW, bran.SPACE)22 self.assertRegexpMatches(spaces, bran.SPACE)23 self.assertRegexpMatches(spaces, bran.SPACES)24 self.assertNotRegexpMatches(empty_string, bran.SPACES)25 self.assertNotRegexpMatches(COW, bran.SPACES) 26 self.assertRegexpMatches(spaces, bran.OPTIONAL_SPACES)27 self.assertRegexpMatches(empty_string, bran.OPTIONAL_SPACES)28 self.assertRegexpMatches(COW, bran.OPTIONAL_SPACES)29 return30 def test_named(self):31 name = "boy"32 expression = COW33 match = re.search(bran.NAMED(n=name, e=expression), "a cow for liebowitz")34 self.assertEqual(expression, match.group(name))35 return36 def test_digit(self):37 digits = "1 2 3 4 5 6 7 8 9 0".split()38 for digit in digits:39 self.assertRegexpMatches(digit, bran.DIGIT)40 self.assertNotRegexpMatches(COW, bran.DIGIT)41 return42 def test_integer(self):43 n1 = "112345"44 n2 = "0.1"45 self.assertRegexpMatches(n1, bran.INTEGER)46 match = re.search(bran.GROUP(e=bran.INTEGER), n2)47 self.assertIsNone(match)48 return49 def test_float(self):50 n1 = '12.3'51 n2 = "11"52 self.assertRegexpMatches(n1, bran.FLOAT)53 self.assertNotRegexpMatches(n2, bran.FLOAT)54 return55 def test_real(self):56 n1 = "0.340"57 n2 = "123"58 match = re.search(bran.GROUP(e=bran.REAL), n1)59 self.assertEqual(n1, match.groups()[0])60 self.assertRegexpMatches(n2, bran.REAL)61 self.assertNotRegexpMatches(COW, bran.REAL)62 return63 def test_class(self):64 s = "Bboy"65 e = bran.CLASS(e="Bb") + "boy"66 self. assertRegexpMatches(s, e)67 def test_single_digit(self):68 self.assertRegexpMatches("0", bran.SINGLE_DIGIT)69 return70 71 def test_two_digits(self):72 self.assertRegexpMatches("19", bran.TWO_DIGITS)73 self.assertRegexpMatches("99", bran.TWO_DIGITS)74 self.assertNotRegexpMatches("9", bran.TWO_DIGITS)75 self.assertNotRegexpMatches("100", bran.TWO_DIGITS)76 return77 78 def test_zero_or_one(self):79 s = "Gb"80 s2 = "Gab"81 s3 = "Gaab"82 e = "G(a)" + bran.ZERO_OR_ONE + 'b'83 self.assertRegexpMatches(s, e)84 match = re.search(e, s)85 self.assertIsNone(match.groups()[0])86 self.assertRegexpMatches(s2, e)87 match = re.search(e, s2)88 self.assertEqual("a", match.groups()[0])89 self.assertNotRegexpMatches(s3, e)90 return91 def test_range(self):92 s = "1"93 s3 = "315"94 s2 = "a" + s3 + "21"95 e = bran.NAMED(n="octet", e=bran.M_TO_N(m=1, n=3, e=bran.DIGIT))96 self.assertRegexpMatches(s, e)97 self.assertRegexpMatches(s2, e)98 self.assertRegexpMatches(s3,e)99 match = re.search(e, s2)100 self.assertEqual(s3, match.group("octet"))101 return102 def test_absolute_range(self):103 s = "a123"104 e = bran.NAMED(n="octet", e=bran.M_TO_N_ONLY(m=1, n=3, e=bran.DIGIT))105 self.assertNotRegexpMatches(s, e)106 return107 108 def test_octet(self):109 name = "octet"110 e = re.compile(bran.NAMED(name,bran.OCTET))111 sources = (str(i) for i in range(256))112 for source in sources:113 match = e.search(source)114 self.assertEqual(source, match.group(name))115 s = "256"116 self.assertNotRegexpMatches(s, bran.OCTET)117 return118 def test_ip_address(self):119 s = "0.0.0.0"120 self.assertRegexpMatches(s, bran.IP_ADDRESS)121 self.assertNotRegexpMatches("256.255.255.255", bran.IP_ADDRESS)122 return123 def test_not(self):124 source = ",,323.5,"125 match = re.search(bran.NAMED('not',bran.NOT(",")), source)126 self.assertEqual(match.group('not'), '323.5')127 self.assertRegexpMatches(",,3,", bran.NOT(","))128 self.assertNotRegexpMatches(",,,,,", bran.NOT(','))...

Full Screen

Full Screen

test_date.py

Source:test_date.py Github

copy

Full Screen

...13 self.assertIn('</uswds-date>', content)14 def test_render_assigns_ids_and_labels(self):15 widget = UswdsDateWidget()16 content = widget.render('boop', None, {'id': 'blarg'})17 self.assertRegexpMatches(content, 'id="blarg_0"')18 self.assertRegexpMatches(content, 'id="blarg_1"')19 self.assertRegexpMatches(content, 'id="blarg_2"')20 self.assertRegexpMatches(content, 'for="blarg_0"')21 self.assertRegexpMatches(content, 'for="blarg_1"')22 self.assertRegexpMatches(content, 'for="blarg_2"')23 def test_render_assigns_names(self):24 widget = UswdsDateWidget()25 content = widget.render('boop', None, {'id': 'foo'})26 self.assertRegexpMatches(content, 'name="boop_0"')27 self.assertRegexpMatches(content, 'name="boop_1"')28 self.assertRegexpMatches(content, 'name="boop_2"')29 def test_render_assigns_hint_id_and_aria_describedby(self):30 widget = UswdsDateWidget()31 content = widget.render('boop', None, {'id': 'foo'})32 self.assertRegexpMatches(content, 'id="foo_hint"')33 self.assertRegexpMatches(content, 'aria-describedby="foo_hint"')34 def test_render_takes_value_as_list(self):35 widget = UswdsDateWidget()36 content = widget.render('boop', [2006, 7, 29], {'id': 'foo'})37 self.assertRegexpMatches(content, 'value="2006"')38 self.assertRegexpMatches(content, 'value="7"')39 self.assertRegexpMatches(content, 'value="29"')40 def test_render_takes_value_as_date(self):41 widget = UswdsDateWidget()42 content = widget.render('boop', date(2005, 6, 28), {'id': 'foo'})43 self.assertRegexpMatches(content, 'value="2005"')44 self.assertRegexpMatches(content, 'value="6"')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful