コード例 #1
0
    def test_can_define_the_output_file(self):
        out_file = StringIO()
        with mock.patch.object(out_file, 'close') as mocked_close:
            with mock.patch('amo2kinto.exporter.open', return_value=out_file):
                exporter.main(['--out', 'file'])
                self.assert_arguments(self.MockedClient)

                self.assertTrue(mocked_close.called)
                self.assertNotEqual(len(out_file.getvalue()), 0)
コード例 #2
0
 def test_last_updated_uses_greater_value(self):
     self.MockedClient.return_value.get_records.side_effect = (
         [ADDONS_DATA], [PLUGIN_DATA], [GFX_DATA], [CERTIFICATE_DATA]
     )
     out_file = StringIO()
     with mock.patch.object(out_file, 'close'):
         with mock.patch('amo2kinto.exporter.open', return_value=out_file):
             exporter.main(['--out', 'file'])
     self.assertIn('lastupdate="1448372434324"', out_file.getvalue())
コード例 #3
0
 def test_get_records_read_fails(self):
     with mock.patch('kinto_http.cli_utils.Client') as MockedClient:
         MockedClient.return_value.get_records.side_effect = Exception
         with mock.patch('amo2kinto.exporter.logger') as mocked_logger:
             exporter.main([])
             self.assertEqual(mocked_logger.warn.call_count, 4)
コード例 #4
0
 def test_can_define_the_auth_credentials(self):
     exporter.main(['--auth', 'user:pass'])
     self.assert_arguments(self.MockedClient, auth=('user', 'pass'))
コード例 #5
0
 def test_can_define_the_plugins_bucket_and_collection(self):
     exporter.main(['--plugins-bucket', 'bucket',
                    '--plugins-collection', 'collection'])
     self.assert_arguments(self.MockedClient,
                           plugins_bucket='bucket',
                           plugins_collection='collection')
コード例 #6
0
 def test_can_define_the_gfx_bucket_and_collection(self):
     exporter.main(['--gfx-bucket', 'bucket',
                    '--gfx-collection', 'collection'])
     self.assert_arguments(self.MockedClient,
                           gfx_bucket='bucket',
                           gfx_collection='collection')
コード例 #7
0
 def test_can_define_the_certificates_bucket_and_collection(self):
     exporter.main(['--certificates-bucket', 'bucket',
                    '--certificates-collection', 'collection'])
     self.assert_arguments(self.MockedClient,
                           certificates_bucket='bucket',
                           certificates_collection='collection')
コード例 #8
0
 def test_main_custom_server(self):
     exporter.main(['-s', 'http://yeah'])
     self.assert_arguments(self.MockedClient, kinto_server='http://yeah')
コード例 #9
0
 def test_main_default(self):
     # let's check that main() parsing uses our defaults
     exporter.main([])
     self.assert_arguments(self.MockedClient)