Beispiel #1
0
    def test_result_object_failed_with_element_def_not_matching_any_element(self):
        html_src = """
                    <html>
                        <p>Content found</p>
                    </html>
                   """

        heading_not_found_def = text('Heading not found')
        text_not_found_def = text('Text not found')
        spec = html(
            heading_not_found_def,
            text('Content found'),
            text_not_found_def
        )

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertFalse(result.passed)
        self.assertTrue(result.failed)
        self.assertEquals(2, len(result.element_defs_not_found))
        self.assertIn(heading_not_found_def, result.element_defs_not_found)
        self.assertIn(text_not_found_def, result.element_defs_not_found)
        self.assertEquals(heading_not_found_def, result.failed_on_def)
Beispiel #2
0
    def test_accordion(self):
        html_src = """
                    <html>
                        <body>
                            <div class="accordion">
                                <div class="accordion-group">
                                    <div class="accordion-heading">
                                        <p>Rick</p>
                                        <a href="www.rick.com">Rick Website</a>
                                        <p>Remove Me</p>
                                    </div>
                                    <div class="accordion-body">
                                        <h1>Foo</h1>
                                    </div>
                                </div>
                                <div class="accordion-group">
                                    <div class="accordion-heading">
                                        <p>Tom</p>
                                        <a href="www.tom.com">Tom Website</a>
                                    </div>
                                    <div class="accordion-body">
                                        <h1>Bar</h1>
                                    </div>
                                </div>
                            </div>
                        </body>
                    </html>
                   """

        spec = html(
            accordion(
                acc_group(
                    acc_heading(
                        text('Rick'),
                        a(href='www.rick.com', link_text='Rick Website')
                    ),
                    acc_body(
                        heading('Foo')
                    )
                ),
                acc_group(
                    acc_heading(
                        text('Tom'),
                        a(href='www.tom.com', link_text='Tom Website')
                    ),
                    acc_body(
                        heading('Bar')
                    )
                )
            )
        )

        self.assert_match(html_src, spec)
Beispiel #3
0
    def test_nested_recursive_middle_element(self):
        html_src = """
                    <html>
                        <h1>Hello</h1>
                        <div>
                            <p>Content</p>
                        </div>
                        <a href="www.google.com">Google</a>
                    </html>
                   """

        spec = html(heading('Hello'), text('Content'),
                    a(href='www.google.com', link_text='Google'))

        self.assert_match(html_src, spec)
Beispiel #4
0
    def test_select_element_xhtml(self):
        html_src = """
                    <html>
                        <select id='abc'>
                            <option value='1'>1</option>
                            <option value='2' selected='selected'>2</option>
                            <option value='3'>3</option>
                        </select>
                    </html>
                   """

        spec = html(
            select('abc', option_xhtml('1', '1'),
                   option_xhtml('2', '2', selected=True), option_xhtml('3')))

        self.assert_match(html_src, spec)
Beispiel #5
0
    def test_index(self, ec2idmock):
        # the available ec2ids
        ec2idmock.return_value = ['ec2ida', 'ec2idb']

        # That a request for the root resource
        response = self.test_client.get('/')

        # Is successful
        self.assertEqual(response.status_code, 200)

        # and returns valid HTML
        self.assertTrue(svalid(response.data))

        spec = pha.html(pha.option("ec2ida"), pha.option("ec2idb"))

        # and contains the two EC2 instance IDs
        results = pha.html_match(spec, response.data)
        self.assertTrue(results.passed)
Beispiel #6
0
    def test_result_object_passing(self):
        html_src = """
                    <html>
                        <p>Content found</p>
                    </html>
                   """

        spec = html(text('Content found'))

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertTrue(result.passed)
        self.assertFalse(result.failed)
        self.assertEquals(0, len(result.element_defs_not_found))
        self.assertIsNone(result.failed_on_def)
Beispiel #7
0
    def test_result_object_passing(self):
        html_src = """
                    <html>
                        <p>Content found</p>
                    </html>
                   """

        spec = html(text('Content found'))

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertTrue(result.passed)
        self.assertFalse(result.failed)
        self.assertEquals(0, len(result.element_defs_not_found))
        self.assertIsNone(result.failed_on_def)
Beispiel #8
0
    def test_nested_recursive_middle_element(self):
        html_src = """
                    <html>
                        <h1>Hello</h1>
                        <div>
                            <p>Content</p>
                        </div>
                        <a href="www.google.com">Google</a>
                    </html>
                   """

        spec = html(
            heading('Hello'),
            text('Content'),
            a(href='www.google.com', link_text='Google')
        )

        self.assert_match(html_src, spec)
Beispiel #9
0
    def test_accordion(self):
        html_src = """
                    <html>
                        <body>
                            <div class="accordion">
                                <div class="accordion-group">
                                    <div class="accordion-heading">
                                        <p>Rick</p>
                                        <a href="www.rick.com">Rick Website</a>
                                        <p>Remove Me</p>
                                    </div>
                                    <div class="accordion-body">
                                        <h1>Foo</h1>
                                    </div>
                                </div>
                                <div class="accordion-group">
                                    <div class="accordion-heading">
                                        <p>Tom</p>
                                        <a href="www.tom.com">Tom Website</a>
                                    </div>
                                    <div class="accordion-body">
                                        <h1>Bar</h1>
                                    </div>
                                </div>
                            </div>
                        </body>
                    </html>
                   """

        spec = html(
            accordion(
                acc_group(
                    acc_heading(
                        text('Rick'),
                        a(href='www.rick.com', link_text='Rick Website')),
                    acc_body(heading('Foo'))),
                acc_group(
                    acc_heading(text('Tom'),
                                a(href='www.tom.com',
                                  link_text='Tom Website')),
                    acc_body(heading('Bar')))))

        self.assert_match(html_src, spec)
Beispiel #10
0
    def test_select_element_xhtml(self):
        html_src = """
                    <html>
                        <select id='abc'>
                            <option value='1'>1</option>
                            <option value='2' selected='selected'>2</option>
                            <option value='3'>3</option>
                        </select>
                    </html>
                   """

        spec = html(
            select('abc',
                   option_xhtml('1', '1'),
                   option_xhtml('2', '2', selected=True),
                   option_xhtml('3')
            )
        )

        self.assert_match(html_src, spec)
Beispiel #11
0
    def test_result_object_failed_with_matcher_not_matched_because_html_out_of_order(self):
        html_src = """
                    <html>
                        <p>Content found</p>
                        <h1>Heading not found</h1>
                    </html>
                   """

        heading_not_found_def = text('Heading not found')
        spec = html(
            heading_not_found_def,
            text('Content found'),
        )

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertFalse(result.passed)
        self.assertTrue(result.failed)
        self.assertEquals(0, len(result.element_defs_not_found))
        self.assertEquals(heading_not_found_def, result.failed_on_def)
Beispiel #12
0
    def test_result_object_failed_with_matcher_not_matched_because_html_out_of_order(
            self):
        html_src = """
                    <html>
                        <p>Content found</p>
                        <h1>Heading not found</h1>
                    </html>
                   """

        heading_not_found_def = text('Heading not found')
        spec = html(
            heading_not_found_def,
            text('Content found'),
        )

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertFalse(result.passed)
        self.assertTrue(result.failed)
        self.assertEquals(0, len(result.element_defs_not_found))
        self.assertEquals(heading_not_found_def, result.failed_on_def)
Beispiel #13
0
    def test_result_object_failed_with_element_def_not_matching_any_element(
            self):
        html_src = """
                    <html>
                        <p>Content found</p>
                    </html>
                   """

        heading_not_found_def = text('Heading not found')
        text_not_found_def = text('Text not found')
        spec = html(heading_not_found_def, text('Content found'),
                    text_not_found_def)

        result = html_match(spec, html_src)

        self.assertEquals(spec, result.spec)
        self.assertEquals(html_src, result.html_src)
        self.assertIsNotNone(result.root_element)
        self.assertFalse(result.passed)
        self.assertTrue(result.failed)
        self.assertEquals(2, len(result.element_defs_not_found))
        self.assertIn(heading_not_found_def, result.element_defs_not_found)
        self.assertIn(text_not_found_def, result.element_defs_not_found)
        self.assertEquals(heading_not_found_def, result.failed_on_def)
Beispiel #14
0
 def test_div_element(self):
     self.assert_match('<html><div class="rob"></div></html>', html(div(class_='rob')))
Beispiel #15
0
 def test_heading_element(self):
     self.assert_match('<html><h1>Hello</h1></html>', heading('Hello'))
     self.assert_match('<html><h3>Hello</h3></html>', html(heading('Hello')))
     self.assert_not_match('<html><h1>Goodbye</h1></html>', heading('Hello'))
Beispiel #16
0
 def test_html_element(self):
     self.assert_match('<html/>', html())
Beispiel #17
0
 def test_html_element(self):
     self.assert_match('<html/>', html())
Beispiel #18
0
    def test_that_fails_when_we_use_the_recursive_parser(self):
        from pha import pretty_spec

        html_src = """
                    <html xmlns="http://www.w3.org/1999/xhtml">
                     <body>
                      <div id="wrap">
                       <div class="navbar-wrapper" MATCH="2">
                        <div class="navbar navbar-inverse navbar-static-top">
                         <div class="navbar-inner">
                          <div class="container">
                           <!-- Navigation menus -->
                           <div class="nav-collapse collapse">
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                       <div class="container">
                        <!-- Support for displaying django user messages -->
                        <!-- Display page heading -->
                        <div class="row-fluid">
                         <span class="span12">
                          <h3 MATCH="3">
                           Users
                          </h3>
                         </span>
                        </div>
                        <!-- Placeholder for the main content pane -->
                        <a class="btn btn-small btn-primary pull-right" href="/accounts/users/new/">
                         <i class="icon-plus icon-white">
                         </i>
                         Create New User
                        </a>
                        <h4>
                         Active Users
                        </h4>
                        <div class="accordion" id="active_users">
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ricklef">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <li>
                                <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                                 <i class="icon-user">
                                 </i>
                                 View Profile
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ricklef_body">
                             <div class="span4">
                              <strong>
                               Ricklef Wohlers (Ricklef)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (admin)
                             </div>
                            </a>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                      </div>
                     </body>
                    </html>
                   """

        spec = html(
            div(
                div(heading('Users')),
                a(href='/accounts/users/new/', link_text='Create New User'),
                heading('Active Users'),
                accordion(
                    acc_group(
                        acc_heading(
                            text('Ricklef Wohlers (Ricklef)'),
                            text('Labminds (admin)'),
                        )))))

        self.assert_match(html_src, spec)
Beispiel #19
0
    def test_big_example(self):
        html_src = """
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                     <head>
                      <title>
                       Users - LabOS
                      </title>
                     </head>
                     <body>
                      <div id="wrap">
                       <div class="navbar-wrapper">
                        <div class="navbar navbar-inverse navbar-static-top">
                         <div class="navbar-inner">
                          <div class="container">
                           <!-- Navigation menus -->
                           <div class="nav-collapse collapse">
                            <ul class="nav">
                             <!-- Admin menu -->
                             <li class="dropdown active" id="admin-dropdown">
                              <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                               Admin
                               <b class="caret">
                               </b>
                              </a>
                              <ul class="dropdown-menu">
                               <li class="nav-header">
                                Manage Users
                               </li>
                               <li>
                                <a href="/accounts/users/">
                                 User List
                                </a>
                               </li>
                               <li>
                                <a href="/accounts/users/new/">
                                 Create New User
                                </a>
                               </li>
                              </ul>
                             </li>
                            </ul>
                            <!-- User menu -->
                            <ul class="nav pull-right">
                             <li class="dropdown" id="user-dropdown">
                              <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                               <i class="icon-user icon-white">
                               </i>
                               <strong>
                                Ricklef
                               </strong>
                               (Labminds)
                               <b class="caret">
                               </b>
                              </a>
                              <ul class="dropdown-menu">
                               <li>
                                <a href="/accounts/users/Ricklef/profile/">
                                 View Profile
                                </a>
                               </li>
                               <li>
                                <a href="/auth/change-password/?next=/accounts/users/">
                                 Change Password
                                </a>
                               </li>
                               <li class="divider">
                               </li>
                               <li>
                                <a href="/accounts/users/feedback">
                                 Feedback
                                </a>
                               </li>
                               <li class="divider">
                               </li>
                               <li>
                                <a href="/auth/logout/">
                                 Logout
                                </a>
                               </li>
                              </ul>
                             </li>
                            </ul>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                       <div class="container">
                        <!-- Support for displaying django user messages -->
                        <!-- Display page heading -->
                        <div class="row-fluid">
                         <span class="span12">
                          <h3>
                           Users
                          </h3>
                         </span>
                        </div>
                        <!-- Placeholder for the main content pane -->
                        <a class="btn btn-small btn-primary pull-right" href="/accounts/users/new/">
                         <i class="icon-plus icon-white">
                         </i>
                         Create New User
                        </a>
                        <h4>
                         Active Users
                        </h4>
                        <div class="accordion" id="active_users">
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ricklef">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <li>
                                <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                                 <i class="icon-user">
                                 </i>
                                 View Profile
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ricklef_body">
                             <div class="span4">
                              <strong>
                               Ricklef Wohlers (Ricklef)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (admin)
                             </div>
                            </a>
                           </div>
                          </div>
                          <div class="accordion-body collapse" id="active_users_Ricklef_body">
                           <div class="accordion-inner">
                            <div class="row-fluid">
                             <div class="span8 well">
                              <table class="table table-condensed">
                               <thead>
                                <tr>
                                 <th colspan="2">
                                  User Details
                                 </th>
                                </tr>
                               </thead>
                               <tr>
                                <td>
                                 Username
                                </td>
                                <td>
                                 Ricklef
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Org Group
                                </td>
                                <td>
                                 Labminds
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Permission Group
                                </td>
                                <td>
                                 admin
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Email Address
                                </td>
                                <td>
                                 [email protected]
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Date Setup
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Last Login
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                              </table>
                             </div>
                             <div class="span4 well">
                              <img src="/static/img/user_icons/male_long.png" width="280"/>
                             </div>
                            </div>
                           </div>
                          </div>
                         </div>
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ville">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ville/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <!-- Activate/deactivate user -->
                               <li>
                                <a href="/accounts/users/Ville/deactivate/">
                                 <i class="icon-remove">
                                 </i>
                                 Deactivate
                                </a>
                               </li>
                               <!-- Change users group -->
                               <li>
                                <a href="/accounts/users/Ville/change-group/admin">
                                 <i class="icon-hand-up">
                                 </i>
                                 Grant Admin Privileges
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ville_body">
                             <div class="span4">
                              <strong>
                               Ville Lehtonen (Ville)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (users)
                             </div>
                            </a>
                           </div>
                          </div>
                          <div class="accordion-body collapse" id="active_users_Ville_body">
                           <div class="accordion-inner">
                            <div class="row-fluid">
                             <div class="span8 well">
                              <table class="table table-condensed">
                               <thead>
                                <tr>
                                 <th colspan="2">
                                  User Details
                                 </th>
                                </tr>
                               </thead>
                               <tr>
                                <td>
                                 Username
                                </td>
                                <td>
                                 Ville
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Org Group
                                </td>
                                <td>
                                 Labminds
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Permission Group
                                </td>
                                <td>
                                 users
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Email Address
                                </td>
                                <td>
                                 [email protected]
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Date Setup
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Last Login
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                              </table>
                             </div>
                             <div class="span4 well">
                              <img src="/static/img/user_icons/male_long.png" width="280"/>
                             </div>
                            </div>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                      </div>
                     </body>
                    </html>
                   """

        spec = html(
            div(
                div(heading('Users')),
                a(href='/accounts/users/new/', link_text='Create New User'),
                heading('Active Users'),
                accordion(
                    acc_group(
                        acc_heading(
                            a(href='/accounts/users/Ricklef/profile/'),
                            text('Ricklef Wohlers (Ricklef)'),
                            text('Labminds (admin)'),
                        )))))

        self.assert_match(html_src, spec)
Beispiel #20
0
 def test_heading_element(self):
     self.assert_match('<html><h1>Hello</h1></html>', heading('Hello'))
     self.assert_match('<html><h3>Hello</h3></html>',
                       html(heading('Hello')))
     self.assert_not_match('<html><h1>Goodbye</h1></html>',
                           heading('Hello'))
Beispiel #21
0
    def test_big_example(self):
        html_src = """
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                     <head>
                      <title>
                       Users - LabOS
                      </title>
                     </head>
                     <body>
                      <div id="wrap">
                       <div class="navbar-wrapper">
                        <div class="navbar navbar-inverse navbar-static-top">
                         <div class="navbar-inner">
                          <div class="container">
                           <!-- Navigation menus -->
                           <div class="nav-collapse collapse">
                            <ul class="nav">
                             <!-- Admin menu -->
                             <li class="dropdown active" id="admin-dropdown">
                              <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                               Admin
                               <b class="caret">
                               </b>
                              </a>
                              <ul class="dropdown-menu">
                               <li class="nav-header">
                                Manage Users
                               </li>
                               <li>
                                <a href="/accounts/users/">
                                 User List
                                </a>
                               </li>
                               <li>
                                <a href="/accounts/users/new/">
                                 Create New User
                                </a>
                               </li>
                              </ul>
                             </li>
                            </ul>
                            <!-- User menu -->
                            <ul class="nav pull-right">
                             <li class="dropdown" id="user-dropdown">
                              <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                               <i class="icon-user icon-white">
                               </i>
                               <strong>
                                Ricklef
                               </strong>
                               (Labminds)
                               <b class="caret">
                               </b>
                              </a>
                              <ul class="dropdown-menu">
                               <li>
                                <a href="/accounts/users/Ricklef/profile/">
                                 View Profile
                                </a>
                               </li>
                               <li>
                                <a href="/auth/change-password/?next=/accounts/users/">
                                 Change Password
                                </a>
                               </li>
                               <li class="divider">
                               </li>
                               <li>
                                <a href="/accounts/users/feedback">
                                 Feedback
                                </a>
                               </li>
                               <li class="divider">
                               </li>
                               <li>
                                <a href="/auth/logout/">
                                 Logout
                                </a>
                               </li>
                              </ul>
                             </li>
                            </ul>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                       <div class="container">
                        <!-- Support for displaying django user messages -->
                        <!-- Display page heading -->
                        <div class="row-fluid">
                         <span class="span12">
                          <h3>
                           Users
                          </h3>
                         </span>
                        </div>
                        <!-- Placeholder for the main content pane -->
                        <a class="btn btn-small btn-primary pull-right" href="/accounts/users/new/">
                         <i class="icon-plus icon-white">
                         </i>
                         Create New User
                        </a>
                        <h4>
                         Active Users
                        </h4>
                        <div class="accordion" id="active_users">
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ricklef">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <li>
                                <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                                 <i class="icon-user">
                                 </i>
                                 View Profile
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ricklef_body">
                             <div class="span4">
                              <strong>
                               Ricklef Wohlers (Ricklef)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (admin)
                             </div>
                            </a>
                           </div>
                          </div>
                          <div class="accordion-body collapse" id="active_users_Ricklef_body">
                           <div class="accordion-inner">
                            <div class="row-fluid">
                             <div class="span8 well">
                              <table class="table table-condensed">
                               <thead>
                                <tr>
                                 <th colspan="2">
                                  User Details
                                 </th>
                                </tr>
                               </thead>
                               <tr>
                                <td>
                                 Username
                                </td>
                                <td>
                                 Ricklef
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Org Group
                                </td>
                                <td>
                                 Labminds
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Permission Group
                                </td>
                                <td>
                                 admin
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Email Address
                                </td>
                                <td>
                                 [email protected]
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Date Setup
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Last Login
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                              </table>
                             </div>
                             <div class="span4 well">
                              <img src="/static/img/user_icons/male_long.png" width="280"/>
                             </div>
                            </div>
                           </div>
                          </div>
                         </div>
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ville">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ville/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <!-- Activate/deactivate user -->
                               <li>
                                <a href="/accounts/users/Ville/deactivate/">
                                 <i class="icon-remove">
                                 </i>
                                 Deactivate
                                </a>
                               </li>
                               <!-- Change users group -->
                               <li>
                                <a href="/accounts/users/Ville/change-group/admin">
                                 <i class="icon-hand-up">
                                 </i>
                                 Grant Admin Privileges
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ville_body">
                             <div class="span4">
                              <strong>
                               Ville Lehtonen (Ville)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (users)
                             </div>
                            </a>
                           </div>
                          </div>
                          <div class="accordion-body collapse" id="active_users_Ville_body">
                           <div class="accordion-inner">
                            <div class="row-fluid">
                             <div class="span8 well">
                              <table class="table table-condensed">
                               <thead>
                                <tr>
                                 <th colspan="2">
                                  User Details
                                 </th>
                                </tr>
                               </thead>
                               <tr>
                                <td>
                                 Username
                                </td>
                                <td>
                                 Ville
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Org Group
                                </td>
                                <td>
                                 Labminds
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Permission Group
                                </td>
                                <td>
                                 users
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Email Address
                                </td>
                                <td>
                                 [email protected]
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Date Setup
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                               <tr>
                                <td>
                                 Last Login
                                </td>
                                <td>
                                 May 13, 2014, 7:35 a.m.
                                </td>
                               </tr>
                              </table>
                             </div>
                             <div class="span4 well">
                              <img src="/static/img/user_icons/male_long.png" width="280"/>
                             </div>
                            </div>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                      </div>
                     </body>
                    </html>
                   """

        spec = html(
            div(
                div(
                    heading('Users')
                ),
                a(href='/accounts/users/new/', link_text='Create New User'),
                heading('Active Users'),
                accordion(
                    acc_group(
                        acc_heading(
                            a(href='/accounts/users/Ricklef/profile/'),
                            text('Ricklef Wohlers (Ricklef)'),
                            text('Labminds (admin)'),
                        )
                    )
                )
            )
        )

        self.assert_match(html_src, spec)
Beispiel #22
0
    def test_that_fails_when_we_use_the_recursive_parser(self):
        from pha import pretty_spec

        html_src = """
                    <html xmlns="http://www.w3.org/1999/xhtml">
                     <body>
                      <div id="wrap">
                       <div class="navbar-wrapper" MATCH="2">
                        <div class="navbar navbar-inverse navbar-static-top">
                         <div class="navbar-inner">
                          <div class="container">
                           <!-- Navigation menus -->
                           <div class="nav-collapse collapse">
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                       <div class="container">
                        <!-- Support for displaying django user messages -->
                        <!-- Display page heading -->
                        <div class="row-fluid">
                         <span class="span12">
                          <h3 MATCH="3">
                           Users
                          </h3>
                         </span>
                        </div>
                        <!-- Placeholder for the main content pane -->
                        <a class="btn btn-small btn-primary pull-right" href="/accounts/users/new/">
                         <i class="icon-plus icon-white">
                         </i>
                         Create New User
                        </a>
                        <h4>
                         Active Users
                        </h4>
                        <div class="accordion" id="active_users">
                         <div class="accordion-group">
                          <div class="accordion-heading row-fluid">
                           <div class="accordion-toggle group-accordion-toggle">
                            <div class="ordericons pull-right dropdown">
                             <!-- User functions -->
                             <div class="btn-group" id="btn_group_Ricklef">
                              <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                               <i class="icon-user icon-white">
                               </i>
                               <span class="hidden-phone">
                                View Profile
                               </span>
                              </a>
                              <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                               <span class="caret">
                               </span>
                              </button>
                              <ul class="dropdown-menu">
                               <li>
                                <a class="btn btn-small btn-primary" href="/accounts/users/Ricklef/profile/">
                                 <i class="icon-user">
                                 </i>
                                 View Profile
                                </a>
                               </li>
                              </ul>
                             </div>
                            </div>
                            <a data-parent="#active_users" data-toggle="collapse" href="#active_users_Ricklef_body">
                             <div class="span4">
                              <strong>
                               Ricklef Wohlers (Ricklef)
                              </strong>
                             </div>
                             <div class="span5 hidden-phone muted">
                              Labminds (admin)
                             </div>
                            </a>
                           </div>
                          </div>
                         </div>
                        </div>
                       </div>
                      </div>
                     </body>
                    </html>
                   """

        spec = html(
            div(
                div(heading('Users')),
                a(href='/accounts/users/new/', link_text='Create New User'),
                heading('Active Users'),
                accordion(
                    acc_group(
                        acc_heading(
                            text('Ricklef Wohlers (Ricklef)'),
                            text('Labminds (admin)'),
                        )
                    )
                )
            )
        )

        self.assert_match(html_src, spec)
Beispiel #23
0
 def test_div_element(self):
     self.assert_match('<html><div class="rob"></div></html>',
                       html(div(class_='rob')))