Пример #1
0
    def test_sign_filename_returns_signature(self):
        with my_vcr.use_cassette('sign_one') as cassette:
            result = self.instance.sign(filename=fixture_path('one.pdf'))

        self.assertEqual(1, len(cassette))
        self.assertIsInstance(result, Signature)
        self.assertIsInstance(result.contents, bytes)
Пример #2
0
 def test_sign_batch(self):
     pdfs = [PDF(fixture_path(filename))
             for filename in ["one.pdf", "two.pdf", "three.pdf"]]
     with my_vcr.use_cassette('sign_batch'):
         self.instance.sign_batch(pdfs)
     from pprint import pprint as pp
     pp([p.out_filename for p in pdfs])
Пример #3
0
    def test_sign_filename_returns_signature(self):
        with my_vcr.use_cassette('sign_one') as cassette:
            result = self.instance.sign(filename=fixture_path('one.pdf'))

        self.assertEqual(1, len(cassette))
        self.assertIsInstance(result, Signature)
        self.assertIsInstance(result.contents, bytes)
Пример #4
0
    def test_wrong_customer_authentication_failed(self):
        bad_instance = AIS(customer="wrong_name", key_static="wrong_key",
                           cert_file=self.cert_file,
                           cert_key=self.cert_key)

        with self.assertRaises(AuthenticationFailed):
            with my_vcr.use_cassette('wrong_customer'):
                bad_instance.sign_one_pdf(PDF(fixture_path('one.pdf')))
Пример #5
0
    def test_sign_single_unprepared_pdf(self):
        self.assertIsNone(self.instance.last_request_id)

        pdf = PDF(fixture_path('one.pdf'))
        with my_vcr.use_cassette('sign_unprepared_pdf'):
            self.instance.sign_one_pdf(pdf)

        self.assertIsNotNone(self.instance.last_request_id)
Пример #6
0
    def test_wrong_customer_authentication_failed(self):
        bad_instance = AIS(customer="wrong_name", key_static="wrong_key",
                           cert_file=self.cert_file,
                           cert_key=self.cert_key)

        with self.assertRaises(AuthenticationFailed):
            with my_vcr.use_cassette('wrong_customer'):
                bad_instance.sign_one_pdf(PDF(fixture_path('one.pdf')))
Пример #7
0
    def test_sign_single_unprepared_pdf(self):
        self.assertIsNone(self.instance.last_request_id)

        pdf = PDF(fixture_path('one.pdf'))
        with my_vcr.use_cassette('sign_unprepared_pdf'):
            self.instance.sign_one_pdf(pdf)

        self.assertIsNotNone(self.instance.last_request_id)
Пример #8
0
 def test_sign_batch(self):
     pdfs = [
         PDF(fixture_path(filename))
         for filename in ["one.pdf", "two.pdf", "three.pdf"]
     ]
     with my_vcr.use_cassette('sign_batch'):
         self.instance.sign_batch(pdfs)
     from pprint import pprint as pp
     pp([p.out_filename for p in pdfs])
Пример #9
0
    def test_sign_batch(self):
        self.assertIsNone(self.instance.last_request_id)

        pdfs = [PDF(fixture_path(filename))
                for filename in ["one.pdf", "two.pdf", "three.pdf"]]
        with my_vcr.use_cassette('sign_batch'):
            self.instance.sign_batch(pdfs)

        self.assertIsNotNone(self.instance.last_request_id)
Пример #10
0
 def test_sign_single_unprepared_pdf(self):
     pdf = PDF(fixture_path('one.pdf'))
     with my_vcr.use_cassette('sign_unprepared_pdf'):
         self.instance.sign_one_pdf(pdf)
Пример #11
0
 def test_sign_single_prepared_pdf(self):
     pdf = PDF(fixture_path('prepared.pdf'), prepared=True)
     with my_vcr.use_cassette('sign_prepared_pdf'):
         self.instance.sign_one_pdf(pdf)
Пример #12
0
 def test_sign_single_unprepared_pdf(self):
     pdf = PDF(fixture_path('one.pdf'))
     with my_vcr.use_cassette('sign_unprepared_pdf'):
         self.instance.sign_one_pdf(pdf)
Пример #13
0
 def test_sign_single_prepared_pdf(self):
     pdf = PDF(fixture_path('prepared.pdf'), prepared=True)
     with my_vcr.use_cassette('sign_prepared_pdf'):
         self.instance.sign_one_pdf(pdf)