Esempio n. 1
0
    def test_send_index_by_file_with_pulling_and_get_status_finish(self):
        # Arrange
        with responses.RequestsMock() as mock:
            mock.add('POST',
                     url=self.full_url + '/files/index',
                     status=201,
                     json={'result_url': '/files/index/testindex'})
            mock.add('GET',
                     url=self.full_url + '/files/index/testindex',
                     status=202)
            mock.add('GET',
                     url=self.full_url + '/files/index/testindex',
                     status=202)
            mock.add('GET',
                     url=self.full_url + '/files/index/testindex',
                     status=200,
                     json={
                         'result_url': '/files/index/testindex',
                         'status': 'succeeded'
                     })
            index = Index(file_path='a', index_as=consts.IndexType.TRUSTED)

            with patch(self.patch_prop, mock_open(read_data='data')):
                # Act
                index.send()
                index.check_status()
                index.check_status()
                index.check_status()

        # Assert
        self.assertEqual(index.status, consts.IndexStatusCode.FINISH)
Esempio n. 2
0
    def test_check_status_before_index_sent_raise_status(self):
        # Arrange
        index = Index(sha256='a', index_as=consts.IndexType.TRUSTED)

        # Act + Assert
        with self.assertRaises(errors.IntezerError):
            index.check_status()