def test_updated_config(self, client, temporary_dataset, project_id):
        config = ExternalConfig(
            slug="old_table",
            spec=self.spec,
            last_modified=pytz.UTC.localize(datetime.datetime.utcnow() +
                                            datetime.timedelta(days=1)),
        )

        client.client.create_table(f"{temporary_dataset}.old_table_day1")
        client.add_labels_to_table(
            "old_table_day1",
            {"last_updated": client._current_timestamp_label()},
        )
        client.client.create_table(f"{temporary_dataset}.old_table_day2")
        client.add_labels_to_table(
            "old_table_day2",
            {"last_updated": client._current_timestamp_label()},
        )

        config_collection = ExternalConfigCollection([config])
        updated_configs = config_collection.updated_configs(
            project_id, temporary_dataset)

        assert len(updated_configs) == 1
        assert updated_configs[0].slug == config.slug
예제 #2
0
    def test_new_config(self, client, project_id, temporary_dataset):
        config = ExternalConfig(
            slug="new_experiment",
            spec=self.spec,
            last_modified=datetime.datetime.utcnow(),
        )
        config_collection = ExternalConfigCollection([config])
        updated_configs = config_collection.updated_configs(
            project_id, temporary_dataset)

        assert len(updated_configs) == 0
 def test_new_config_without_a_table_is_marked_changed(
         self, client, temporary_dataset, project_id):
     config = ExternalConfig(
         slug="my_cool_experiment",
         spec=self.spec,
         last_modified=pytz.UTC.localize(datetime.datetime.utcnow()),
     )
     config_collection = ExternalConfigCollection([config])
     updated_configs = config_collection.updated_configs(
         project_id, temporary_dataset)
     assert [updated.slug
             for updated in updated_configs] == ["my_cool_experiment"]
예제 #4
0
    def test_from_github_repo(self):
        external_configs = ExternalConfigCollection.from_github_repo()
        assert external_configs

        example_conf = external_configs.spec_for_experiment("example_config")
        assert example_conf is not None

        assert external_configs.spec_for_experiment(
            "not-existing-conf") is None