def test_skip_download_if_already_downloaded_and_still_valid(self):
        when(os.path).exists(self.pem_path).thenReturn(True)
        when(certs).should_redownload(ANY()).thenReturn(False)
        cert = SmtpClientCertificate(self.provider, self.auth, self.tmp_dir.name)
        result = cert.cert_path()

        self.assertEqual(self.pem_path, result)
        verify(self.downloader, never).download_to(ANY())
    def test_download_certificate_if_redownload_necessary_e_g_certificate_expired(self):
        self.pretend_all_paths_exist()
        when(certs).should_redownload(self.pem_path).thenReturn(True)

        cert = SmtpClientCertificate(self.provider, self.auth, self.tmp_dir.name)
        result = cert.cert_path()

        self.assertEqual(self.pem_path, result)
        verify(self.downloader).download_to(self.pem_path)
    def test_download_certificate(self):
        cert = SmtpClientCertificate(self.provider, self.auth, self.tmp_dir.name)
        result = cert.cert_path()

        self.assertEqual(self.pem_path, result)
        verify(self.downloader).download_to(self.pem_path)