Exemplo n.º 1
0
    def test_parse_job_to_file__multiple_rows(self):

        SAMPLE_SIMPLE_JOB = {
            'lambda_name': self.LABOURER.id,
            "isolate_sections": True,
            'sections': {
                'section_technic': None,
                'section_furniture': None,
            },
        }

        self.scheduler.parse_job_to_file(SAMPLE_SIMPLE_JOB)

        self.assertEqual(line_count(self.scheduler.local_queue_file), 2)

        with open(self.scheduler.local_queue_file, 'r') as f:
            for row in f.readlines():
                # print(row)
                parsed_row = json.loads(row)
                print(parsed_row)

                self.assertEqual(parsed_row['labourer_id'], self.LABOURER.id)
                self.assertEqual(len(parsed_row['sections']), 1)
                self.assertIn(parsed_row['sections'][0],
                              SAMPLE_SIMPLE_JOB['sections'])
Exemplo n.º 2
0
    def test_parse_job_to_file(self):

        SAMPLE_SIMPLE_JOB = {
            'lambda_name': self.LABOURER.id,
            'some_payload': 'foo',
        }

        self.scheduler.parse_job_to_file(SAMPLE_SIMPLE_JOB)

        self.assertEqual(line_count(self.scheduler.local_queue_file), 1)

        with open(self.scheduler.local_queue_file, 'r') as f:
            row = json.loads(f.read())
            print(row)

            self.assertEqual(row['labourer_id'], self.LABOURER.id)
            self.assertEqual(row['some_payload'], 'foo')
Exemplo n.º 3
0
    def test_get_and_lock_queue_file(self):
        self.put_file(only_remote=True)

        # Check old artifacts
        self.assertFalse(
            self.exists_in_s3(self.scheduler._remote_queue_locked_file))
        self.assertTrue(self.exists_in_s3(self.scheduler._remote_queue_file))

        r = self.scheduler.get_and_lock_queue_file()

        self.assertEqual(r, self.scheduler._local_queue_file)

        self.assertTrue(
            self.exists_in_s3(self.scheduler._remote_queue_locked_file))
        self.assertFalse(self.exists_in_s3(self.scheduler._remote_queue_file))

        number_of_lines = line_count(self.scheduler._local_queue_file)
        # print(f"Number of lines: {number_of_lines}")
        self.assertTrue(number_of_lines, 10)