class TestShellApplication(unittest.TestCase):
    def setUp(self):
        self.shell_app = ShellApplication()

    def test_init(self):
        self.assertTrue(self.shell_app.running)

    def test_signal_handler(self):
        self.shell_app.signal_handler()
        self.assertFalse(self.shell_app.running)
Example #2
0
class TestShellApplication(unittest.TestCase):

    def setUp(self):
        self.shell_app = ShellApplication()

    def test_init(self):
        self.assertTrue(self.shell_app.running)

    def test_signal_handler(self):
        self.shell_app.signal_handler()
        self.assertFalse(self.shell_app.running)
 def setUp(self):
     self.server_url = 'https://test.url/'
     self.api_path = '/api/downstream/v1'
     self.size = 100
     self.address = base58.b58encode_check(b'\x00' + os.urandom(20))
     self.token = binascii.hexlify(os.urandom(16)).decode('ascii')
     self.msg = ''
     self.sig = ''
     self.thread_manager = ShellApplication()
     self.contract_thread = ManagedThread()
     self.chunk_dir = os.path.join('data', 'chunks')
     self.client = DownstreamClient(self.server_url, self.token,
                                    self.address, self.size, self.msg,
                                    self.sig, self.thread_manager,
                                    self.chunk_dir)
     self.client.session = mock.MagicMock()
     self.test_contract = \
         DownstreamContract(self.client,
                            MockValues.get_chunks_response[
                                'chunks'][0]['file_hash'],
                            MockValues.get_chunks_response[
                                'chunks'][0]['seed'],
                            MockValues.get_chunks_response[
                                'chunks'][0]['size'],
                            Heartbeat.challenge_type().fromdict(
                                MockValues
                                .get_chunks_response
                                ['chunks'][0]['challenge']),
                            datetime.utcnow() + timedelta(
                                seconds=int(
                                    MockValues
                                    .get_chunks_response
                                    ['chunks'][0]['due'])),
                            Heartbeat.tag_type().fromdict(
                                MockValues
                                .get_chunks_response
                                ['chunks'][0]['tag']),
                            self.thread_manager,
                            self.chunk_dir)
     self.test_heartbeat = Heartbeat.fromdict(
         MockValues.connect_response['heartbeat'])
Example #4
0
 def setUp(self):
     self.shell_app = ShellApplication()
 def setUp(self):
     self.shell_app = ShellApplication()