Exemple #1
0
    def test_get_with_unexpected_response(self):
        self.setup_connection(
            MAASFileStorage, FakeFileStorageReturningUnexpectedError)
        storage = MAASFileStorage(CONFIG)
        d = storage.get("foo")

        return self.assertFailure(d, ProviderInteractionError)
Exemple #2
0
    def test_get_succeeds(self):
        self.setup_connection(MAASFileStorage, FakeFileStorage)
        storage = MAASFileStorage(CONFIG)
        d = storage.get("foo")

        def check(value):
            # The underlying code returns a StringIO but because
            # implementations of StringIO and cStringIO are completely
            # different the only reasonable thing to do here is to
            # check to see if the returned object has a "read" method.
            attr = getattr(value, "read")
            self.assertIsNot(None, attr)
            self.assertTrue(value.read)

        d.addCallback(check)
        d.addErrback(self.fail)
        return d
Exemple #3
0
    def test_get_with_bad_filename(self):
        self.setup_connection(MAASFileStorage, FakeFileStorageReturning404)
        storage = MAASFileStorage(CONFIG)
        d = storage.get("foo")

        return self.assertFailure(d, FileNotFound)