Esempio n. 1
0
    def test_load_data(self):
        status = self.status
        assert status.data() == status.default_data()
        assert status.load_data().data() == status.default_data()
        assert status.get_files_count() == 0
        for i in range(1, 100):
            assert status.add_completed()
            assert status.get_completed() == i

            assert status.add_failed()
            assert status.get_failed() == i

            assert status.add_file()
            assert status.get_files_copied() == i

            assert status.add_in_progress()
            assert status.get_in_progress() == 1

            assert status.add_to_be_processed()
            assert status.get_files_to_process() == i

            assert status.set_stopped()
            assert status.get_current_status() == Processing_Status.STOPPED

            assert status.set_started()
            assert status.get_current_status() == Processing_Status.STARTED

            assert status.set_phase_1()
            assert status.get_current_status() == Processing_Status.PHASE_1

            assert status.set_phase_2()
            assert status.get_current_status() == Processing_Status.PHASE_2

        assert json_load_file(status.status_file_path()) == status.data()
Esempio n. 2
0
    def setUp(self) -> None:
        self.analysis_json = Analysis_Json()
        self.storage   = self.analysis_json.storage
        report_file_path = os.path.join(FIXTURE_DIR, 'report.json')
        assert os.path.isfile(report_file_path)

        self.report_data = json_load_file(report_file_path)
Esempio n. 3
0
 async def test_get_last_chrome_session(self):
     self.chrome.keep_open()
     browser = await self.chrome.browser()
     assert set(
         json_load_file(
             self.chrome.chrome_setup.file_tmp_last_chrome_session)) == {
                 'process_args', 'process_id', 'port', 'when', 'url_chrome'
             }
     await browser.close()
 def test_update_status(self):
     temp_data_file = temp_file()
     with patch.object(Hash_Json, 'get_file_path', return_value=temp_data_file):
         self.hash_json.add_file(self.test_file_hash, self.test_file_name)
         assert self.hash_json.data()[self.test_file_hash]['file_status'] == 'Initial'
         self.hash_json.update_status(self.test_file_hash, 'BBBB')
         self.hash_json.save()
         assert self.hash_json.data()[self.test_file_hash]['file_status'] == 'BBBB'
         assert json_load_file(temp_data_file)[self.test_file_hash]['file_status'] == 'BBBB'
     pprint(self.hash_json.load())
 def test_save(self):
     target_file = temp_file()                                                   # temp file to save data
     assert file_not_exists(target_file)                                         # confirm it doesn't exist
     with patch.object(Hash_Json, 'get_file_path', return_value=target_file):    # patch get_file_path to return temp file path
         assert self.hash_json.get_file_path() == target_file                    # confirm patch is in place
         self.hash_json.save()                                          # call write_to_file
         assert file_exists(target_file)                                         # confirm temp file now exists
         assert self.hash_json.load() == self.hash_json.data()                     # confirm reloaded data is correct
         assert json_load_file(target_file)    == self.hash_json.data()            # also confirm using direct json load of temp file
     assert self.hash_json.get_file_path()     != target_file                    # confirm pathc is not there (after 'with' ends)
     file_delete(target_file)                                                    # delete temp file
    def setUp(self) -> None:

        events_file_path = os.path.join(FIXTURE_DIR, 'events.json')
        assert os.path.isfile(events_file_path)

        self.events_data = json_load_file(events_file_path)

        self.events_log_elastic = Events_Log_Elastic()
        self.events_log_elastic.setup()

        if self.events_log_elastic.enabled is False:
            pytest.skip('Elastic server not available')
Esempio n. 7
0
    def setUp(self) -> None:

        report_file_path = os.path.join(FIXTURE_DIR, 'report.json')
        assert os.path.isfile(report_file_path)

        self.report_data = json_load_file(report_file_path)

        self.original_hash = self.report_data['original_hash']
        assert self.original_hash == self.file_hash

        self.report_elastic = Report_Elastic()
        self.report_elastic.setup()

        if self.report_elastic.enabled is False:
            pytest.skip('Elastic server not available')
    def setUp(self) -> None:

        analysis_file_path = os.path.join(FIXTURE_DIR, 'analysis.json')
        assert os.path.isfile(analysis_file_path)

        self.analysis_data = json_load_file(analysis_file_path)
        assert self.analysis_data is not None
        assert len(self.analysis_data) == 6

        self.original_hash = self.analysis_data[
            self.file_hash]['original_hash']
        assert self.original_hash == self.file_hash

        self.analysis_elastic = Analysis_Elastic()
        self.analysis_elastic.setup()

        if self.analysis_elastic.enabled is False:
            pytest.skip('Elastic server not available')
 def load_data(self):
     self._status_data = json_load_file(self.status_file_path())
     if self.data() == {}:
         self.reset()
     return self
Esempio n. 10
0
 def get_last_chrome_session(self):
     if file_exists(self.file_tmp_last_chrome_session):
         return json_load_file(self.file_tmp_last_chrome_session)
     return {}
Esempio n. 11
0
 def load(self):
     self._hash_json_data = json_load_file(self.get_file_path())
     return self.data()
Esempio n. 12
0
 def test_json_load_file__json_save_tmp_file(self):
     data = {'answer': 42}
     json_file = json_save_tmp_file(data)
     assert file_exists(json_file)
     assert json_load_file(json_file) == data
     assert file_exists(json_file)
Esempio n. 13
0
 def get_from_file(self):
     self.analysis_data = json_load_file(self.get_file_path())
     return self.analysis_data
 def test_dashboards(self):
     dashboards = json_load_file(
         '/var/folders/_j/frqs70d93l328f307rw2jx5h0000gn/T/tmp628dz7n_.tmp')
     dashboard = dashboards[0]
     dashboard_id = dashboard.get('id')
     pprint(dashboard)