Esempio n. 1
0
    def test_task_entity_get_files(self):
        core_snapshot_entity = CoreSnapshot(self.input_dict)
        snapshot_entity = Snapshot(core_snapshot_entity)
        # Test failure because entity has not been created by controller
        failed = False
        try:
            snapshot_entity.get_files()
        except DoesNotExist:
            failed = True
        assert failed

        # Test success
        snapshot_entity = self.__setup()
        result = snapshot_entity.get_files()

        assert len(result) == 1
        assert isinstance(result[0], TextIOWrapper)
        assert result[0].mode == "r"
        assert "script.py" in result[0].name

        snapshot_entity = self.__setup()
        result = snapshot_entity.get_files(mode="a")

        assert len(result) == 1
        assert isinstance(result[0], TextIOWrapper)
        assert result[0].mode == "a"
        assert "script.py" in result[0].name
Esempio n. 2
0
    def test_snapshot_entity_instantiate(self):
        core_snapshot_entity = CoreSnapshot(self.input_dict)
        snapshot_entity = Snapshot(core_snapshot_entity)

        for k, v in self.input_dict.items():
            if k != "file_collection_id":
                assert getattr(snapshot_entity, k) == v
        assert snapshot_entity.task_id == None
        assert snapshot_entity.label == None
        assert snapshot_entity.created_at
Esempio n. 3
0
    def test_snapshot_entity_instantiate(self):
        input_dict = {
            "id": "test",
            "model_id": "my_model",
            "session_id": "my_session",
            "message": "my test snapshot",
            "code_id": "my_code",
            "environment_id": "my_environment",
            "file_collection_id": "my_files",
            "config": {},
            "stats": {}
        }
        core_snapshot_entity = CoreSnapshot(input_dict)
        snapshot_entity = Snapshot(core_snapshot_entity, home=self.temp_dir)

        for k, v in input_dict.items():
            assert getattr(snapshot_entity, k) == v
        assert snapshot_entity.task_id == None
        assert snapshot_entity.label == None
        assert snapshot_entity.created_at