def test_streams(self): """ Check that calling streams() returns all the registered streams visible to anonymous user. """ with fixtures.created_bundle_streams(self.pathnames): response = self.xml_rpc_call('streams') self.assertEqual(response, self.expected_response)
def test_bundles_failure(self): with fixtures.created_bundle_streams(self.bundle_streams): try: self.xml_rpc_call("bundles", self.query) except xmlrpclib.Fault as ex: self.assertEqual(ex.faultCode, errors.NOT_FOUND) else: self.fail("Should have raised an exception")
def test_put_failure(self): with fixtures.created_bundle_streams([] if getattr(self, 'do_not_create', False) else [self.pathname]), fixtures.created_bundles(getattr(self, 'bundles', [])): try: self.xml_rpc_call( "put", self.content, self.content_filename, self.pathname) except xmlrpclib.Fault as ex: self.assertEqual(ex.faultCode, self.faultCode) else: self.fail("Should have raised an exception")
def test_deserialize_failure_does_not_kill_the_bundle(self): _pathname = '/anonymous/' _content = '"unterminated string' _content_filename = 'bad.json' # The test goes via the xml-rpc interface to use views calling the # put() API directly will never trigger transactions handling with fixtures.created_bundle_streams([_pathname]): self.content_sha1 = self.xml_rpc_call( "put", _content, _content_filename, _pathname) self.assertEqual(Bundle.objects.all().count(), 1)
def test_listed_bundles_are_the_ones_we_should_see(self): with fixtures.created_bundle_streams(self.bundle_streams) as bundle_streams: response = self.client.get(self.url) expected_bsl = sorted( [bundle_stream.pk for bundle_stream in bundle_streams if bundle_stream.is_accessible_by(self.user)]) effective_bsl = sorted( [bundle_stream.pk for bundle_stream in response.context['bundle_stream_table'].data.queryset]) self.assertEqual(effective_bsl, expected_bsl)
def test_listed_bundles_are_the_ones_we_should_see(self): with fixtures.created_bundle_streams( self.bundle_streams) as bundle_streams: response = self.client.get(self.url) expected_bsl = sorted([ bundle_stream.pk for bundle_stream in bundle_streams if bundle_stream.is_accessible_by(self.user) ]) effective_bsl = sorted([ bundle_stream.pk for bundle_stream in response.context['bundle_stream_table'].data.queryset ]) self.assertEqual(effective_bsl, expected_bsl)
def test_bundles(self): """ Make a bunch of bundles (all in a public branch) and check that they are returned by the XML-RPC request. """ with fixtures.created_bundle_streams(self.bundle_streams), fixtures.created_bundles(self.bundles): results = self.xml_rpc_call('bundles', self.query) self.assertEqual(len(results), len(self.expected_results)) with fixtures.test_loop(zip(results, self.expected_results)) as loop_items: for result, expected_result in loop_items: self.assertEqual( result['content_filename'], expected_result['content_filename']) self.assertEqual( result['content_sha1'], expected_result['content_sha1'])