예제 #1
0
            def send_mother(self):

                worker = BasicUserParseWorker("https://www.reddit.com/user/Chrikelnel")

                data = worker.recv(self.buff_size)
                original_target = None
                send_to_mother(self, data, original_target)
예제 #2
0
    def test_worker_send_to_mothership(self):
        worker = BasicUserParseWorker("https://www.reddit.com/user/Chrikelnel")
        test_data = "test_data"
        test_root = "root"

        # Set up our own socket on the mothership port.
        # Precondition: ip in settings.py for mothership is localhost

        s = socket.socket()
        addr = (settings.MOTHERSHIP['host'], settings.MOTHERSHIP['port'])
        s.bind(addr)
        s.listen(5)

        worker.send_to_mother(test_data, test_root)

        worker, address = s.accept()
        data = worker.recv(1024)
        data = json.loads(data.decode('ascii'))

        self.assertEqual(data['data'], test_data)
        self.assertEqual(data['root'], test_root)

        worker.close()
        s.close()