def runTest(self):
     print "  handling bad logins",
     self.assertRaises(wikibrowser.BadLoginError, self.browser.loadWiki,
                       USER_URL, randomString(), PASSWORD)
     self.assertRaises(wikibrowser.BadLoginError, self.browser.loadWiki,
                       USER_URL, USERNAME, randomString())
     print "OK"
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need wikipedia login"
            USERNAME = raw_input("username: "******"http://en.wikipedia.org/wiki/User:%s" % USERNAME  # everyone gets their own test page
        self.browser = wikibrowser.Browser()
        # get real stuff
        br = wikibrowser.Browser()  # extra browser for getting test info
        br.open("http://en.wikipedia.org/wiki/Special:ListFiles")
        fileLink = re.compile('.*File:.*')
        self.realFileNames = [
            link.text for link in br.links(url_regex=fileLink)
        ]
        self.realFileNames = [
            name for name in self.realFileNames if name != ''
        ]
        self.realCode = \
{"http://en.wikipedia.org/wiki/User:Jeffdjohnson":
        """[[/map code sandbox]]

[[/screenshot sandbox]]
""",
        "http://en.wikipedia.org/wiki/Trafford_Park":
        """and Urmston]]
|post_town= MANCHESTER
|postcode_area= M
|postcode_district= M17
|dial_code= 0161
|os_grid_reference= SJ785965
|static_image= [[Image:Trafford Park.png|240px]]
|static_image_caption=<small>A view over Trafford Park, from [[Eccles, Greater Manchester|Eccles]]</small>
}}
"""}
        self.pagesToUploadTo = [
            "http://en.wikipedia.org/wiki/User:Jeffdjohnson",
            "http://en.wikipedia.org/wiki/User:Jeffdjohnson/map_code_sandbox2"
        ]
        # make up fake stuff
        self.fakeImageNames = [
            randomString() + random.choice((".png", ".jpg"))
            for num in range(10)
        ]
        self.filesToUpload = [
            os.path.realpath(TEST_IMAGES + "/" + name)
            for name in os.listdir(TEST_IMAGES)
        ]
        self.fakeCode = \
{"http://en.wikipedia.org/wiki/Talk:Trafford_Park":
        """As written, the article, citing Canal Archive appeared to state that the Fourth Baronet de Trafford had been the landowner who strongly opposed the ship canal in the early 1880s. In fact, Sir Humphrey de Trafford, the Second Baronet was the landowner at this time. He died in 1886, and his son Sir Humphrey Francis de Trafford, was more positive towards the canal. Therefore I have removed the text mentioning the "4th Sir Humphrey de Traff
""",
        "http://en.wikipedia.org/wiki/Portal:Geography":
        "[[thisi skaldfhkasjdf lkusy fhsadkf jh"}
        self.codeToUpload = [
            "random test link: [[%s]]" % randomString(30),
            "and then there's this"
        ]
 def setUp(self):
     # basic setup
     global USERNAME
     global PASSWORD
     if '' in (USERNAME, PASSWORD): # first setUp
         print "need jeffwiki login"
         USERNAME = raw_input("Username: "******"http://wikidust.sbolstandard.org/index.php/Special:ListFiles")
     fileLink = re.compile('.*File:.*')
     self.realFileNames = [link.text for link in br.links(url_regex=fileLink)]
     self.correctURLs = {"index":  "http://wikidust.sbolstandard.org/index.php",
                         "login":  "******",
                         "upload": "http://wikidust.sbolstandard.org/index.php/Special:Upload"}
     self.editablePages    = ("http://wikidust.sbolstandard.org/index.php?title=Sandbox:Imagemaps",
                              "http://wikidust.sbolstandard.org/index.php?title=Sandbox:Randompage")
     self.nonEditablePages = ("http://wikidust.sbolstandard.org/index.php/Main_Page",
                              "http://wikidust.sbolstandard.org/index.php/Special:BrokenRedirects",
                              "http://wikidust.sbolstandard.org/index.php/Special:RecentChanges")
     #TODO make this jeffwiki-specific
     self.viewablePages    = ("http://en.wikipedia.org/wiki/Obama_%28disambiguation%29",
                              "http://en.wikipedia.org/wiki/Barack_Obama")
     self.realCode = {"http://wikidust.sbolstandard.org/index.php/Sandbox:Imagemaps": 
                      "</imagemap>"}
     self.pagesToUploadTo = ("http://wikidust.sbolstandard.org/index.php?title=Sandbox:Imagemaps",)
     # make up fake stuff
     self.fakeImageNames = [randomString()+random.choice((".png", ".jpg")) for num in range(10)]
     self.fakeCode = {"http://wikidust.sbolstandard.org/index.php?title=Sandbox:Imagemaps":
                      "this isn';t really in the page"}
     self.codeToUpload = ["random test link: [[%s]]" % randomString(30),
                          "and then there's this"]
     self.filesToUpload = [os.path.realpath(TEST_IMAGES + "/" + name) for name in os.listdir(TEST_IMAGES)]
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need UW NetID"
            USERNAME = raw_input("username: "******"index":  "https://courses.washington.edu/synbio/goldenbricks/index.php",
                            "login":  "******",
                            "upload": "https://courses.washington.edu/synbio/goldenbricks/index.php?title=Special:Upload"}
        br = wikibrowser.Browser()
        br.loadWiki(USER_URL, USERNAME, PASSWORD)
        br.open( "%s?title=Special:ListFiles" % self.correctURLs["index"] )
        fileLink = re.compile('.*File:.*')
        self.realFileNames = [link.text for link in br.links(url_regex=fileLink)]
        self.realCode = \
{"https://courses.washington.edu/synbio/goldenbricks/index.php?title=Main_Page":
"""==Some test space below for demonstrating wiki things==
[[Test]]
[[Test1]]
"""}
        self.pagesToUploadTo = ("https://courses.washington.edu/synbio/goldenbricks/index.php?title=Test2",)
        self.codeToUpload = ["random test link: [[%s]]" % randomString(30),
                             "and then there's this"]
        self.lockedPages = ["https://courses.washington.edu/synbio/goldenbricks/index.php?title=Oscillators"]
        # fake stuff
        self.fakeImageNames = [randomString()+random.choice((".png", ".jpg")) for num in range(10)]
        self.filesToUpload = [os.path.realpath(TEST_IMAGES + "/" + name) for name in os.listdir(TEST_IMAGES)]
        self.fakeCode = \
{"https://courses.washington.edu/synbio/goldenbricks/index.php?title=Main_Page":
"""==Some test spaceas needed fslku jfh jhhh this [[stuff]]
"""}
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need igem login"
            USERNAME = raw_input("username: "******"http://2010.igem.org/Special:ImageList")
        fileLink = re.compile('.*Image:.*')
        self.realFileNames = [link.text for link in br.links(url_regex=fileLink)]
        self.realCode = {"http://2010.igem.org/Team:Washington/Code_testing": '<area shape="rect" coords="'}
        self.pagesToUploadTo = ["http://2010.igem.org/Team:Washington/Tools Created/New Software/Testing"]
        self.codeToUpload = ["random test link: [[%s]]" % randomString(30), "and then there's this"]
        # make up fake stuff
        self.fakeImageNames = [randomString()+random.choice((".png", ".jpg")) for num in range(10)]
        self.filesToUpload = [TEST_IMAGES + name for name in os.listdir(TEST_IMAGES)]
        self.fakeCode = \
{"http://2011.igem.org/wiki/index.php?title=Main_Page":
"""<p>iGEM 2011 Teachers Workshop details have been finalized.
<ul>
<li><span style="font-weight:bold">27 May: Carmona, Spain</span>
</ul
</p>
""",
"http://2011.igem.org/Oil_Sands":
"[[File:OSLIiGEM2011sm2.JPG|link=http://www.osli.a/newideas/apply|center]]",
"http://2011.igem.org/Oil_Sands":
"this isn';t ev[[][[][]en remortuykj close***"
}
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need registry (igem) login"
            USERNAME = raw_input("username: "******"http://partsregistry.org/Special:ImageList")
        fileLink = re.compile('.*Image:.*')
        self.realFileNames = [
            link.text for link in br.links(url_regex=fileLink)
        ]
        self.realCode = \
{"http://partsregistry.org/Help:Spring_2011_DNA_distribution": "=What's included in the Spring 2011 Distribution=",
        "http://partsregistry.org/Main_Page": 'The Registry is based on the principle of "get some, give some".'}
        # make up fake stuff
        self.fakeImageNames = [
            randomString() + random.choice((".png", ".jpg"))
            for num in range(10)
        ]
        self.filesToUpload = [
            os.path.realpath(TEST_IMAGES + "/" + name)
            for name in os.listdir(TEST_IMAGES)
        ]
        self.fakeCode = \
{"http://partsregistry.org/Main_Page":
        """est new features here | See new features here
Related resources & links

    iGEM
    The BioBricks Foundation
    OpenWetWare
    BioBrick Assembly Kit a
""",
        "http://partsregistry.org/wiki/index.php/Part:BBa_K145010":
        """<!-- -->
<span class='h3bb'>Sequence and Features</span>
<partinfo>BBa_K145010 SequenceAndFeatures</partinfo>

stuff
<!-- Uncomment this to enable Functional Parameter display 
===Functional Parameters===
<partinfo>BBa_K145010 parameters</partinfo>
<!-- -->
"""}
        self.codeToUpload = [
            "random test link: [[%s]]" % randomString(30),
            "and then there's this"
        ]
        self.pagesToUploadTo = [
            "http://partsregistry.org/wiki/index.php?title=Part:BBa_K314000"
        ]
Exemple #7
0
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need igem login"
            USERNAME = raw_input("username: "******"http://2010.igem.org/Special:ImageList")
        fileLink = re.compile('.*Image:.*')
        self.realFileNames = [
            link.text for link in br.links(url_regex=fileLink)
        ]
        self.realCode = {
            "http://2010.igem.org/Team:Washington/Code_testing":
            '<area shape="rect" coords="'
        }
        self.pagesToUploadTo = [
            "http://2010.igem.org/Team:Washington/Tools Created/New Software/Testing"
        ]
        self.codeToUpload = [
            "random test link: [[%s]]" % randomString(30),
            "and then there's this"
        ]
        # make up fake stuff
        self.fakeImageNames = [
            randomString() + random.choice((".png", ".jpg"))
            for num in range(10)
        ]
        self.filesToUpload = [
            TEST_IMAGES + name for name in os.listdir(TEST_IMAGES)
        ]
        self.fakeCode = \
{"http://2011.igem.org/wiki/index.php?title=Main_Page":
        """<p>iGEM 2011 Teachers Workshop details have been finalized.
<ul>
<li><span style="font-weight:bold">27 May: Carmona, Spain</span>
</ul
</p>
""",
        "http://2011.igem.org/Oil_Sands":
        "[[File:OSLIiGEM2011sm2.JPG|link=http://www.osli.a/newideas/apply|center]]",
        "http://2011.igem.org/Oil_Sands":
        "this isn';t ev[[][[][]en remortuykj close***"
        }
    def setUp(self):
        global USERNAME
        global PASSWORD
        if '' in (USERNAME, PASSWORD):
            print "need wikipedia login"
            USERNAME = raw_input("username: "******"http://en.wikipedia.org/wiki/User:%s" % USERNAME # everyone gets their own test page
        self.browser = wikibrowser.Browser()
        # get real stuff
        br = wikibrowser.Browser() # extra browser for getting test info
        br.open("http://en.wikipedia.org/wiki/Special:ListFiles")
        fileLink = re.compile('.*File:.*')
        self.realFileNames = [link.text for link in br.links(url_regex=fileLink)]
        self.realFileNames = [name for name in self.realFileNames if name != '']
        self.realCode = \
{"http://en.wikipedia.org/wiki/User:Jeffdjohnson":
"""[[/map code sandbox]]

[[/screenshot sandbox]]
""",
"http://en.wikipedia.org/wiki/Trafford_Park":
"""and Urmston]]
|post_town= MANCHESTER
|postcode_area= M
|postcode_district= M17
|dial_code= 0161
|os_grid_reference= SJ785965
|static_image= [[Image:Trafford Park.png|240px]]
|static_image_caption=<small>A view over Trafford Park, from [[Eccles, Greater Manchester|Eccles]]</small>
}}
"""}
        self.pagesToUploadTo = ["http://en.wikipedia.org/wiki/User:Jeffdjohnson",
                                "http://en.wikipedia.org/wiki/User:Jeffdjohnson/map_code_sandbox2"]
        # make up fake stuff
        self.fakeImageNames = [randomString()+random.choice((".png", ".jpg")) for num in range(10)]
        self.filesToUpload = [os.path.realpath(TEST_IMAGES + "/" + name) for name in os.listdir(TEST_IMAGES)]
        self.fakeCode = \
{"http://en.wikipedia.org/wiki/Talk:Trafford_Park":
"""As written, the article, citing Canal Archive appeared to state that the Fourth Baronet de Trafford had been the landowner who strongly opposed the ship canal in the early 1880s. In fact, Sir Humphrey de Trafford, the Second Baronet was the landowner at this time. He died in 1886, and his son Sir Humphrey Francis de Trafford, was more positive towards the canal. Therefore I have removed the text mentioning the "4th Sir Humphrey de Traff
""",
"http://en.wikipedia.org/wiki/Portal:Geography":
"[[thisi skaldfhkasjdf lkusy fhsadkf jh"}
        self.codeToUpload = ["random test link: [[%s]]" % randomString(30), "and then there's this"]
    def setUp(self):
        global USERNAME
        global PASSWORD
        if "" in (USERNAME, PASSWORD):
            print "need registry (igem) login"
            USERNAME = raw_input("username: "******"http://partsregistry.org/Special:ImageList")
        fileLink = re.compile(".*Image:.*")
        self.realFileNames = [link.text for link in br.links(url_regex=fileLink)]
        self.realCode = {
            "http://partsregistry.org/Help:Spring_2011_DNA_distribution": "=What's included in the Spring 2011 Distribution=",
            "http://partsregistry.org/Main_Page": 'The Registry is based on the principle of "get some, give some".',
        }
        # make up fake stuff
        self.fakeImageNames = [randomString() + random.choice((".png", ".jpg")) for num in range(10)]
        self.filesToUpload = [os.path.realpath(TEST_IMAGES + "/" + name) for name in os.listdir(TEST_IMAGES)]
        self.fakeCode = {
            "http://partsregistry.org/Main_Page": """est new features here | See new features here
Related resources & links

    iGEM
    The BioBricks Foundation
    OpenWetWare
    BioBrick Assembly Kit a
""",
            "http://partsregistry.org/wiki/index.php/Part:BBa_K145010": """<!-- -->
<span class='h3bb'>Sequence and Features</span>
<partinfo>BBa_K145010 SequenceAndFeatures</partinfo>

stuff
<!-- Uncomment this to enable Functional Parameter display 
===Functional Parameters===
<partinfo>BBa_K145010 parameters</partinfo>
<!-- -->
""",
        }
        self.codeToUpload = ["random test link: [[%s]]" % randomString(30), "and then there's this"]
        self.pagesToUploadTo = ["http://partsregistry.org/wiki/index.php?title=Part:BBa_K314000"]
 def runTest(self):
     print "  handling bad URL",
     self.assertRaises(wikibrowser.BadURLError, self.browser.loadWiki,
                       randomString(), USERNAME, PASSWORD)
     print "OK"
 def runTest(self):
     print "  handling bad logins",
     self.assertRaises( wikibrowser.BadLoginError, self.browser.loadWiki, USER_URL, randomString(), PASSWORD )
     self.assertRaises( wikibrowser.BadLoginError, self.browser.loadWiki, USER_URL, USERNAME, randomString() )
     print "OK"
 def runTest(self):
     print "  handling bad URL",
     self.assertRaises( wikibrowser.BadURLError,   self.browser.loadWiki, randomString(), USERNAME, PASSWORD )
     print "OK"