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')
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')
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())
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())
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)
def test_no_certs_post_fx58(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', '--app', constants.FIREFOX_APPID, '--app-version', '58.0']) self.assertNotIn('<certItems>', out_file.getvalue())
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)
def test_can_define_the_auth_credentials(self): exporter.main(['--auth', 'user:pass']) self.assert_arguments(self.MockedClient, auth=('user', 'pass'))
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')
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')
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')
def test_main_custom_server(self): exporter.main(['-s', 'http://yeah']) self.assert_arguments(self.MockedClient, kinto_server='http://yeah')
def test_main_default(self): # let's check that main() parsing uses our defaults exporter.main([]) self.assert_arguments(self.MockedClient)
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')