Exemplo n.º 1
0
    def test_is_configured(self):
        # If an ExternalIntegration exists, the API is_configured
        assert True == NoveListAPI.is_configured(self._default_library)
        # A class variable is set to reduce future database requests.
        assert self._default_library.id == NoveListAPI._configuration_library_id

        # If an ExternalIntegration doesn't exist for the library, it is not.
        library = self._library()
        assert False == NoveListAPI.is_configured(library)
        # And the class variable is updated.
        assert library.id == NoveListAPI._configuration_library_id
Exemplo n.º 2
0
    def test_is_configured(self):
        # If an ExternalIntegration exists, the API is_configured
        eq_(True, NoveListAPI.is_configured(self._default_library))
        # A class variable is set to reduce future database requests.
        eq_(self._default_library.id, NoveListAPI._configuration_library_id)

        # If an ExternalIntegration doesn't exist for the library, it is not.
        library = self._library()
        eq_(False, NoveListAPI.is_configured(library))
        # And the class variable is updated.
        eq_(library.id, NoveListAPI._configuration_library_id)
Exemplo n.º 3
0
    def test_is_configured(self):
        # If an ExternalIntegration exists, the API is_configured
        eq_(True, NoveListAPI.is_configured(self._default_library))
        # A class variable is set to reduce future database requests.
        eq_(self._default_library.id, NoveListAPI._configuration_library_id)

        # If an ExternalIntegration doesn't exist for the library, it is not.
        library = self._library()
        eq_(False, NoveListAPI.is_configured(library))
        # And the class variable is updated.
        eq_(library.id, NoveListAPI._configuration_library_id)
Exemplo n.º 4
0
 def setup(self):
     super(TestNoveListAPI, self).setup()
     self.integration = self._external_integration(
         ExternalIntegration.NOVELIST,
         ExternalIntegration.METADATA_GOAL, username=u'library',
         password=u'yep', libraries=[self._default_library]
     )
     self.novelist = NoveListAPI.from_config(self._default_library)
Exemplo n.º 5
0
 def setup(self):
     super(TestNoveListAPI, self).setup()
     with temp_config() as config:
         config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
             Configuration.NOVELIST_PROFILE: "library",
             Configuration.NOVELIST_PASSWORD: "******"
         }
         self.novelist = NoveListAPI.from_config(self._db)
Exemplo n.º 6
0
 def setup(self):
     super(TestNoveListAPI, self).setup()
     with temp_config() as config:
         config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
             Configuration.NOVELIST_PROFILE : "library",
             Configuration.NOVELIST_PASSWORD : "******"
         }
         self.novelist = NoveListAPI.from_config(self._db)
Exemplo n.º 7
0
 def setup(self):
     super(TestNoveListAPI, self).setup()
     self.integration = self._external_integration(
         ExternalIntegration.NOVELIST,
         ExternalIntegration.METADATA_GOAL, username=u'library',
         password=u'yep', libraries=[self._default_library],
     )
     self.novelist = NoveListAPI.from_config(self._default_library)
Exemplo n.º 8
0
 def setup_method(self):
     super(TestNoveListAPI, self).setup_method()
     self.integration = self._external_integration(
         ExternalIntegration.NOVELIST,
         ExternalIntegration.METADATA_GOAL,
         username="******",
         password="******",
         libraries=[self._default_library],
     )
     self.novelist = NoveListAPI.from_config(self._default_library)
Exemplo n.º 9
0
    def test_from_config(self):
        """Confirms that NoveListAPI can be built from config successfully"""
        novelist = NoveListAPI.from_config(self._default_library)
        eq_(True, isinstance(novelist, NoveListAPI))
        eq_("library", novelist.profile)
        eq_("yep", novelist.password)

        # Without either configuration value, an error is raised.
        self.integration.password = None
        assert_raises(ValueError, NoveListAPI.from_config, self._default_library)

        self.integration.password = u'yep'
        self.integration.username = None
        assert_raises(ValueError, NoveListAPI.from_config, self._default_library)
Exemplo n.º 10
0
    def test_from_config(self):
        """Confirms that NoveListAPI can be built from config successfully"""
        novelist = NoveListAPI.from_config(self._default_library)
        eq_(True, isinstance(novelist, NoveListAPI))
        eq_("library", novelist.profile)
        eq_("yep", novelist.password)

        # Without either configuration value, an error is raised.
        self.integration.password = None
        assert_raises(CannotLoadConfiguration, NoveListAPI.from_config, self._default_library)

        self.integration.password = u'yep'
        self.integration.username = None
        assert_raises(CannotLoadConfiguration, NoveListAPI.from_config, self._default_library)
Exemplo n.º 11
0
    def test_from_config(self):
        """Confirms that NoveListAPI can be built from config successfully"""
        novelist = NoveListAPI.from_config(self._default_library)
        assert True == isinstance(novelist, NoveListAPI)
        assert "library" == novelist.profile
        assert "yep" == novelist.password

        # Without either configuration value, an error is raised.
        self.integration.password = None
        pytest.raises(
            CannotLoadConfiguration, NoveListAPI.from_config, self._default_library
        )

        self.integration.password = "******"
        self.integration.username = None
        pytest.raises(
            CannotLoadConfiguration, NoveListAPI.from_config, self._default_library
        )
Exemplo n.º 12
0
    def test_from_config(self):
        """Confirms that NoveListAPI can be built from config successfully"""

        with temp_config() as config:
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PROFILE: "library",
                Configuration.NOVELIST_PASSWORD: "******"
            }
            novelist = NoveListAPI.from_config(self._db)
            eq_(True, isinstance(novelist, NoveListAPI))
            eq_("library", novelist.profile)
            eq_("yep", novelist.password)

            # Without either configuration value, an error is raised.
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PROFILE: "library"
            }
            assert_raises(ValueError, NoveListAPI.from_config, self._db)
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PASSWORD: "******"
            }
            assert_raises(ValueError, NoveListAPI.from_config, self._db)
Exemplo n.º 13
0
    def test_from_config(self):
        """Confirms that NoveListAPI can be built from config successfully"""

        with temp_config() as config:
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PROFILE : "library",
                Configuration.NOVELIST_PASSWORD : "******"
            }
            novelist = NoveListAPI.from_config(self._db)
            eq_(True, isinstance(novelist, NoveListAPI))
            eq_("library", novelist.profile)
            eq_("yep", novelist.password)

            # Without either configuration value, an error is raised.
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PROFILE : "library"
            }
            assert_raises(ValueError, NoveListAPI.from_config, self._db)
            config['integrations'][Configuration.NOVELIST_INTEGRATION] = {
                Configuration.NOVELIST_PASSWORD : "******"
            }
            assert_raises(ValueError, NoveListAPI.from_config, self._db)