<commit_before>from handler_fixture import StationHandlerTestCast

from groundstation.transfer.request_handlers import handle_listallchannels
from groundstation.gref import Gref
from groundstation.objects.root_object import RootObject



class TestHandlerListAllChannels(StationHandlerTestCast):
    def test_handle_listallchannels(self):
        test_id = "tests/1"
        test_channel = "test_channel"
        test_protocol = "test_protocol"

        obj = RootObject(test_id, test_channel, test_protocol)
        gref = Gref(self.station.station.store, test_channel, test_id)

        oid = self.station.station.write(obj.as_object())
        self.station.station.update_gref(gref, [oid], [])

        handle_listallchannels(self.station)
        response = self.station.stream.pop()
        assert len(self.station.stream) == 0, "Someone is leaving objects lyind around"
        print response.payload<commit_msg>Flesh out the testsuite<commit_after>from handler_fixture import StationHandlerTestCast

from groundstation.transfer.request_handlers import handle_listallchannels
from groundstation.gref import Gref
from groundstation.objects.root_object import RootObject
from groundstation.proto.channel_list_pb2 import ChannelList



class TestHandlerListAllChannels(StationHandlerTestCast):
    def test_handle_listallchannels(self):
        test_id = u"tests/1"
        test_channel = u"test_channel"
        test_protocol = u"test_protocol"

        obj = RootObject(test_id, test_channel, test_protocol)
        gref = Gref(self.station.station.store, test_channel, test_id)

        oid = self.station.station.write(obj.as_object())
        self.station.station.update_gref(gref, [oid], [])

        handle_listallchannels(self.station)
        response = self.station.stream.pop()
        serialized_response = response.SerializeToString()
        self.assertIsInstance(serialized_response, str)
        assert len(self.station.stream) == 0, "Someone is leaving objects lyind around"
        channel_description = ChannelList()
        channel_description.ParseFromString(response.payload)
        self.assertEqual(channel_description.channels[0].channelname, test_channel)
        self.assertEqual(channel_description.channels[0].grefs[0].name, test_id)
        self.assertEqual(channel_description.channels[0].grefs[0].tips[0].tip, oid)
{'fraction_non_alphanumeric': 0.08556832694763729, 'fraction_numerical': 0.004682843763303533, 'mean_word_length': 4.222222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2475503', 'n_tokens_mistral': 671, 'n_tokens_neox': 653, 'n_words': 121}