Beispiel #1
0
    def test_all_returns_correct_output_metric_names(self, mock_projects,
                                                     mock_jobs):
        from foundations_core_rest_api_components.lazy_result import LazyResult

        mock_jobs.return_value = LazyResult(lambda: [
            self.MockJob(
                job_id="123",
                job_parameters=[],
                output_metrics=[{
                    "name": "metric_1",
                    "type": "list"
                }],
            )
        ])

        mock_projects.list_projects.return_value = [{"name": "project1"}]

        project = Project.all().evaluate()[0]
        expected_project = Project(name="project1",
                                   created_at=None,
                                   owner=None,
                                   jobs=[
                                       self.MockJob(job_id="123",
                                                    job_parameters=[],
                                                    output_metrics=[])
                                   ],
                                   output_metric_names=[{
                                       "name": "metric_1",
                                       "type": "list"
                                   }],
                                   parameters=[])
        self.assertCountEqual(expected_project.output_metric_names,
                              project.output_metric_names)
Beispiel #2
0
    def test_all_returns_all_projects_multiple_projects(
            self, mock_projects, mock_jobs):
        from foundations_core_rest_api_components.lazy_result import LazyResult

        mock_jobs.return_value = LazyResult(
            lambda:
            [self.MockJob(job_id="123", job_parameters=[], output_metrics=[])])

        mock_projects.list_projects.return_value = [
            {
                "name": "project1"
            },
            {
                "name": "project2"
            },
        ]

        projects = [project for project in Project.all().evaluate()]

        expected_project = Project(name="project1",
                                   created_at=None,
                                   owner=None,
                                   jobs=[
                                       self.MockJob(job_id="123",
                                                    job_parameters=[],
                                                    output_metrics=[])
                                   ],
                                   output_metric_names=[],
                                   parameters=[])
        expected_project_two = Project(name="project2",
                                       created_at=None,
                                       owner=None,
                                       jobs=[
                                           self.MockJob(job_id="123",
                                                        job_parameters=[],
                                                        output_metrics=[])
                                       ],
                                       output_metric_names=[],
                                       parameters=[])
        self.assertEqual([expected_project, expected_project_two], projects)
Beispiel #3
0
 def test_all_returns_all_projects_using_correct_redis(
         self, mock_projects, mock_redis):
     Project.all().evaluate()
     mock_projects.list_projects.assert_called_with(mock_redis)