def test_missing_auth(self):
     musicbrainz.auth("", "")
     musicbrainz._useragent = "test"
     self.assertRaises(musicbrainzngs.UsageError,
                       musicbrainz._mb_request,
                       path="foo",
                       auth_required=musicbrainz.AUTH_YES)
 def test_auth_headers_ifset(self):
     musicbrainz._useragent = "test"
     musicbrainz.auth("user", "password")
     req = musicbrainz._mb_request(path="foo",
                                   auth_required=musicbrainz.AUTH_IFSET)
     assert (any([
         isinstance(handler, musicbrainz._DigestAuthHandler)
         for handler in self.opener.handlers
     ]))
 def test_auth_headers_ifset_no_user(self):
     musicbrainz._useragent = "test"
     musicbrainz.auth("", "")
     # if no user and password, auth is not set for AUTH_IFSET
     req = musicbrainz._mb_request(path="foo",
                                   auth_required=musicbrainz.AUTH_IFSET)
     assert (not any([
         isinstance(handler, musicbrainz._DigestAuthHandler)
         for handler in self.opener.handlers
     ]))
    def setUp(self):
        self.opener = _common.FakeOpener("<response/>")
        musicbrainzngs.compat.build_opener = lambda *args: self.opener

        musicbrainz.auth("user", "password")
Exemplo n.º 5
0
 def setUp(self):
     self.orig_opener = musicbrainzngs.compat.build_opener
     musicbrainz.set_useragent("test_client", "1.0")
     musicbrainz.auth("user", "password")
    def setUp(self):
        self.opener = _common.FakeOpener("<response/>")
        musicbrainzngs.compat.build_opener = lambda *args: self.opener

        musicbrainz.auth("user", "password")
 def setUp(self):
     musicbrainz.auth("user", "password")
Exemplo n.º 8
0
 def setUp(self):
     musicbrainz.auth("user", "password")