-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from kronos-et-al/b/int/image_scheduler
B/int/image scheduler
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use async_trait::async_trait; | ||
use mensa_app_backend::{ | ||
interface::mealplan_management::MensaParseScheduling, | ||
layer::{ | ||
data::{ | ||
database::factory::DataAccessFactory, flickr_api::flickr_api_handler::FlickrApiHandler, | ||
}, | ||
logic::image_review::image_reviewer::ImageReviewer, | ||
trigger::scheduling::scheduler::{ScheduleInfo, Scheduler}, | ||
}, | ||
startup::config::ConfigReader, | ||
}; | ||
use tokio::signal::ctrl_c; | ||
|
||
const NEVER: &str = "* * * 31 2 *"; | ||
|
||
#[tokio::test] | ||
#[ignore = "manual test"] | ||
async fn test_image_scheduling() { | ||
let mut scheduler = setup().await; | ||
scheduler.start().await; | ||
ctrl_c().await.unwrap(); | ||
scheduler.shutdown().await; | ||
} | ||
|
||
async fn setup() -> Scheduler { | ||
let info = ScheduleInfo { | ||
full_parse_schedule: NEVER.to_string(), | ||
update_parse_schedule: NEVER.to_string(), | ||
image_review_schedule: "0 */5 * * * *".to_string(), | ||
}; | ||
let reader = ConfigReader::default(); | ||
let database_factory = DataAccessFactory::new(reader.read_database_info().unwrap(), false) | ||
.await | ||
.unwrap(); | ||
let image_review_data = database_factory.get_image_review_data_access(); | ||
let image_hoster = FlickrApiHandler::new(reader.read_flickr_info().unwrap()); | ||
let image_scheduling = ImageReviewer::new(image_review_data, image_hoster); | ||
Scheduler::new(info, image_scheduling, MealplanManagerMock::default()).await | ||
} | ||
|
||
#[derive(Default)] | ||
struct MealplanManagerMock {} | ||
|
||
#[async_trait] | ||
impl MensaParseScheduling for MealplanManagerMock { | ||
async fn start_update_parsing(&self) { | ||
return; | ||
} | ||
|
||
async fn start_full_parsing(&self) { | ||
return; | ||
} | ||
} |