Esempio n. 1
0
    def test_constructor(self):
        # The constructor must be given an Enki collection.
        collection = self._collection(protocol=ExternalIntegration.OVERDRIVE)
        with pytest.raises(ValueError) as excinfo:
            EnkiAPI(self._db, collection)
        assert "Collection protocol is Overdrive, but passed into EnkiAPI!" in str(
            excinfo.value)

        collection.protocol = ExternalIntegration.ENKI
        EnkiAPI(self._db, collection)
Esempio n. 2
0
    def test_constructor(self):
        # The constructor must be given an Enki collection.
        collection = self._collection(protocol=ExternalIntegration.OVERDRIVE)
        assert_raises_regexp(
            ValueError,
            "Collection protocol is Overdrive, but passed into EnkiAPI!",
            EnkiAPI, self._db, collection)

        collection.protocol = ExternalIntegration.ENKI
        EnkiAPI(self._db, collection)
Esempio n. 3
0
    def test_constructor(self):

        bad_collection = self._collection(
            protocol=ExternalIntegration.OVERDRIVE)
        assert_raises_regexp(
            ValueError,
            "Collection protocol is Overdrive, but passed into EnkiAPI!",
            EnkiAPI, self._db, bad_collection)

        # Without an external_account_id, an EnkiAPI cannot be instantiated.
        bad_collection.protocol = ExternalIntegration.ENKI
        assert_raises_regexp(CannotLoadConfiguration,
                             "Enki configuration is incomplete.", EnkiAPI,
                             self._db, bad_collection)

        bad_collection.external_account_id = "1"
        EnkiAPI(self._db, bad_collection)
Esempio n. 4
0
 def test_create_identifier_strings(self):
     identifier = self._identifier(identifier_type=Identifier.ENKI_ID)
     values = EnkiAPI.create_identifier_strings(["foo", identifier])
     eq_(["foo", identifier.identifier], values)
Esempio n. 5
0
 def test__epoch_to_struct(self):
     """Test the _epoch_to_struct helper method."""
     eq_(datetime.datetime(1970, 1, 1), EnkiAPI._epoch_to_struct("0"))
Esempio n. 6
0
 def test__minutes_since(self):
     """Test the _minutes_since helper method."""
     an_hour_ago = datetime.datetime.utcnow() - datetime.timedelta(
         minutes=60)
     eq_(60, EnkiAPI._minutes_since(an_hour_ago))
Esempio n. 7
0
 def test__epoch_to_struct(self):
     """Test the _epoch_to_struct helper method."""
     assert datetime_utc(1970, 1, 1) == EnkiAPI._epoch_to_struct("0")
Esempio n. 8
0
 def test__minutes_since(self):
     """Test the _minutes_since helper method."""
     an_hour_ago = utc_now() - datetime.timedelta(minutes=60)
     assert 60 == EnkiAPI._minutes_since(an_hour_ago)
Esempio n. 9
0
 def test__epoch_to_struct(self):
     """Test the _epoch_to_struct helper method."""
     eq_(datetime.datetime(1970, 1, 1), EnkiAPI._epoch_to_struct("0"))
Esempio n. 10
0
 def test__minutes_since(self):
     """Test the _minutes_since helper method."""
     an_hour_ago = datetime.datetime.utcnow() - datetime.timedelta(
         minutes=60
     )
     eq_(60, EnkiAPI._minutes_since(an_hour_ago))