예제 #1
0
    def test_refresh_meta_data_returns_true_on_force_refresh(self):
        sp = ServiceProvider(
            local_metadata=XML,
            metadata_expiration_dt=timezone.now() + timedelta(hours=1),
        )

        assert sp.refresh_metadata(True) is True
예제 #2
0
    def test_refresh_metadata_updates_metadata_expiration_dt_from_remote(self):
        sp = ServiceProvider(
            metadata_expiration_dt=timezone.now(),
            remote_metadata_url="http://someremote",
        )
        with requests_mock.mock() as m:
            m.get(sp.remote_metadata_url, text=XML)
            refreshed = sp.refresh_metadata()

        assert refreshed
        assert sp.local_metadata == XML
예제 #3
0
    def test_refresh_meta_data_returns_true_on_force_refresh(self):
        sp = ServiceProvider(
            local_metadata=EXPIRED_XML,
            metadata_expiration_dt=timezone.now() + timedelta(hours=1),
            remote_metadata_url="http://someremote",
        )

        with requests_mock.mock() as m:
            m.get(sp.remote_metadata_url, text=VALID_XML)
            refreshed = sp.refresh_metadata(True)

        assert refreshed
        assert sp.local_metadata == VALID_XML
예제 #4
0
 def test_refresh_meta_data_returns_false_on_model_state(self):
     instance = ServiceProvider(
         local_metadata=timezone.now(),
         metadata_expiration_dt=timezone.now() + timedelta(hours=1),
     )
     assert instance.refresh_metadata() is False