Takumi IINO avatar Takumi IINO committed 480da0c

fix fork finding for new bb ui

Comments (0)

Files changed (2)

 
     try:
         # there are 2 ol for the listings, first is forks, second is mqs
-        descendants = tree.find('//ol[@class="detailed iterable"]')[0]
+        descendants = tree.xpath('//h2[text()="Forks"]')[0].getnext()
+        if descendants.find('.[@class="detailed iterable"]') is None:
+            return []
         forklist = descendants.findall('.//dd[@class="name"]')
         # Item 0 is a link to the user profile and item 1 is the link to the
         # forked repo.
 # bb will have a single link to the repo overview in case of lack of forks
 example_bbforks_page_no_forks = """
 <div class="forks pane">
-    <ol><li><span><a href="testrepo">no forks here</a></span></li></ol>
+    <h2>Forks</h2>
+    <p>No forks of <a href="testrepo">testrepo</a> yet.</p>
+    <h2>Patch queues</h2>
+    <p>No patch queues of <a href="testrepo">testrepo</a> yet.</p>
 </div>
 """
 
 example_bbforks_page_with_forks = """
 <body>
     <div class="forks pane">
-        <ol>
+        <h2>Forks</h2>
+        <ol class="detailed iterable">
             <li>
-                <span><a href="/special">special</a> / <a href="/special/testrepo/overview">ow</a></span><br />
-                <a href="https://bitbucket.org/special/testrepo"> </a>
+                <dd class="name"><a href="/special">special</a> / <a href="/special/testrepo">ow</a></dd><br />
+            </li>
+            <li>
+                <dd class="name"><a href="/special">special</a> / <a href="/special/testrepo2">ow2</a></dd><br />
+            </li>
+        </ol>
+        <h2>Patch queues</h2>
+        <ol class="detailed iterable">
+            <li>
+                <dd class="name"><a href="/special-patches">special-patches</a> / <a href="/special/testrepo-patches">ow</a></dd><br />
             </li>
         </ol>
     </div>
     monkeypatch.setattr(lxml.html, 'parse', parse)
     repos = hgbb.list_forks('testrepo')
     print repos
-    assert repos == ['special/testrepo']
+    assert repos == ['special/testrepo', 'special/testrepo2']
 
 
 def test_list_forks_failes(monkeypatch):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.