Changeset bd1cbde in trunk
- Timestamp:
- 2020-04-18T07:52:17Z (5 years ago)
- Branches:
- master
- Children:
- b4fab44
- Parents:
- 76516fe
- git-author:
- meejah <meejah@…> (2019-12-28 02:00:20)
- git-committer:
- meejah <meejah@…> (2020-04-18 07:52:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/test/web/test_web.py ¶
r76516fe rbd1cbde 1893 1893 return d 1894 1894 1895 def _check_upload_and_mkdir_forms(self, html): 1896 # We should have a form to create a file, with radio buttons that allow 1897 # the user to toggle whether it is a CHK/LIT (default), SDMF, or MDMF file. 1898 self.failUnless(re.search('<input (name="t" |value="upload" |type="hidden" ){3}/>', html), html) 1899 self.failUnless(re.search('<input [^/]*id="upload-chk"', html), html) 1900 self.failUnless(re.search('<input [^/]*id="upload-sdmf"', html), html) 1901 self.failUnless(re.search('<input [^/]*id="upload-mdmf"', html), html) 1902 1903 # We should also have the ability to create a mutable directory, with 1904 # radio buttons that allow the user to toggle whether it is an SDMF (default) 1905 # or MDMF directory. 1906 self.failUnless(re.search('<input (name="t" |value="mkdir" |type="hidden" ){3}/>', html), html) 1907 self.failUnless(re.search('<input [^/]*id="mkdir-sdmf"', html), html) 1908 self.failUnless(re.search('<input [^/]*id="mkdir-mdmf"', html), html) 1909 1910 self.failUnlessIn(FAVICON_MARKUP, html) 1911 1895 def _check_upload_and_mkdir_forms(self, soup): 1896 """ 1897 Confirm `soup` contains a form to create a file, with radio 1898 buttons that allow the user to toggle whether it is a CHK/LIT 1899 (default), SDMF, or MDMF file. 1900 """ 1901 found = [] 1902 desired_ids = ( 1903 u"upload-chk", 1904 u"upload-sdmf", 1905 u"upload-mdmf", 1906 u"mkdir-sdmf", 1907 u"mkdir-mdmf", 1908 ) 1909 for input_tag in soup.find_all(u"input"): 1910 if input_tag.get(u"id", u"") in desired_ids: 1911 found.append(input_tag) 1912 else: 1913 if input_tag.get(u"name", u"") == u"t" and input_tag.get(u"type", u"") == u"hidden": 1914 if input_tag[u"value"] == u"upload": 1915 found.append(input_tag) 1916 elif input_tag[u"value"] == u"mkdir": 1917 found.append(input_tag) 1918 self.assertEqual(len(found), 7, u"Failed to find all 7 <input> tags") 1919 assert_soup_has_favicon(self, soup) 1920 1921 @inlineCallbacks 1912 1922 def test_GET_DIRECTORY_html(self): 1913 d = self.GET(self.public_url + "/foo", followRedirect=True) 1914 def _check(html): 1915 self.failUnlessIn('<li class="toolbar-item"><a href="../../..">Return to Welcome page</a></li>', html) 1916 self._check_upload_and_mkdir_forms(html) 1917 self.failUnlessIn("quux", html) 1918 d.addCallback(_check) 1919 return d 1923 data = yield self.GET(self.public_url + "/foo", followRedirect=True) 1924 soup = BeautifulSoup(data, 'html5lib') 1925 self._check_upload_and_mkdir_forms(soup) 1926 toolbars = soup.find_all(u"li", {u"class": u"toolbar-item"}) 1927 self.assertTrue(any(li.text == u"Return to Welcome page" for li in toolbars)) 1928 self.failUnlessIn("quux", data) 1920 1929 1921 1930 def test_GET_DIRECTORY_html_filenode_encoding(self): … … 1937 1946 return d 1938 1947 1948 @inlineCallbacks 1939 1949 def test_GET_root_html(self): 1940 d =self.GET("/")1941 d.addCallback(self._check_upload_and_mkdir_forms)1942 return d1950 data = yield self.GET("/") 1951 soup = BeautifulSoup(data, 'html5lib') 1952 self._check_upload_and_mkdir_forms(soup) 1943 1953 1944 1954 def test_GET_DIRURL(self):
Note: See TracChangeset
for help on using the changeset viewer.