test: Created snapshot tests for all Radarr UI modules
This commit is contained in:
@@ -41,7 +41,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}],
|
||||
@@ -231,7 +231,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}],
|
||||
@@ -319,7 +319,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}],
|
||||
@@ -348,7 +348,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}],
|
||||
|
||||
@@ -604,7 +604,7 @@ mod tests {
|
||||
Description: Blah blah blah
|
||||
TMDB: 99%
|
||||
IMDB: 9.9
|
||||
Rotten Tomatoes:
|
||||
Rotten Tomatoes: 99%
|
||||
Quality Profile: HD - 1080p
|
||||
Size: 3.30 GB
|
||||
Path: /nfs/movies
|
||||
@@ -921,7 +921,7 @@ mod tests {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -22,12 +22,10 @@ mod root_folders;
|
||||
mod system;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "radarr_network_tests.rs"]
|
||||
mod radarr_network_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "radarr_network_test_utils.rs"]
|
||||
mod radarr_network_test_utils;
|
||||
pub mod radarr_network_test_utils;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub enum RadarrEvent {
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
#[cfg(test)]
|
||||
pub(in crate::network::radarr_network) mod test_utils {
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
pub mod test_utils {
|
||||
use crate::models::radarr_models::{
|
||||
AddMovieSearchResult, BlocklistItem, BlocklistItemMovie, Collection, CollectionMovie, Credit,
|
||||
CreditType, DownloadRecord, DownloadsResponse, IndexerSettings, MediaInfo, MinimumAvailability,
|
||||
Movie, MovieCollection, MovieFile, MovieHistoryItem, RadarrRelease, Rating, RatingsList,
|
||||
Movie, MovieCollection, MovieFile, MovieHistoryItem, RadarrRelease, RadarrTask, RadarrTaskName,
|
||||
Rating, RatingsList,
|
||||
};
|
||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
||||
use crate::models::servarr_models::{
|
||||
Indexer, IndexerField, Language, Quality, QualityWrapper, RootFolder,
|
||||
DiskSpace, Indexer, IndexerField, Language, Quality, QualityWrapper, QueueEvent, RootFolder,
|
||||
};
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
use bimap::BiMap;
|
||||
use chrono::DateTime;
|
||||
use indoc::formatdoc;
|
||||
use serde_json::{Number, Value, json};
|
||||
|
||||
pub const MOVIE_JSON: &str = r#"{
|
||||
@@ -42,7 +46,7 @@ pub(in crate::network::radarr_network) mod test_utils {
|
||||
"value": 9.9
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
},
|
||||
"movieFile": {
|
||||
@@ -86,10 +90,10 @@ pub(in crate::network::radarr_network) mod test_utils {
|
||||
"value": 9.9
|
||||
},
|
||||
"tmdb": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
},
|
||||
"rottenTomatoes": {
|
||||
"value": 9.9
|
||||
"value": 99
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +108,49 @@ pub(in crate::network::radarr_network) mod test_utils {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn diskspace() -> DiskSpace {
|
||||
DiskSpace {
|
||||
free_space: 6500,
|
||||
total_space: 8675309,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log_line() -> &'static str {
|
||||
"2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases"
|
||||
}
|
||||
|
||||
pub fn task() -> RadarrTask {
|
||||
RadarrTask {
|
||||
name: "Backup".to_string(),
|
||||
task_name: RadarrTaskName::Backup,
|
||||
interval: 60,
|
||||
last_execution: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:29:16Z").unwrap()),
|
||||
last_duration: "00:00:17".to_string(),
|
||||
next_execution: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T22:29:16Z").unwrap()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn queued_event() -> QueueEvent {
|
||||
QueueEvent {
|
||||
trigger: "manual".to_string(),
|
||||
name: "Refresh Monitored Downloads".to_string(),
|
||||
command_name: "Refresh Monitored Downloads".to_string(),
|
||||
status: "completed".to_string(),
|
||||
queued: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:25:16Z").unwrap()),
|
||||
started: Some(DateTime::from(
|
||||
DateTime::parse_from_rfc3339("2023-05-20T21:25:30Z").unwrap(),
|
||||
)),
|
||||
ended: Some(DateTime::from(
|
||||
DateTime::parse_from_rfc3339("2023-05-20T21:28:33Z").unwrap(),
|
||||
)),
|
||||
duration: Some("00:03:03".to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tags_map() -> BiMap<i64, String> {
|
||||
BiMap::from_iter([(1, "alex".to_owned())])
|
||||
}
|
||||
|
||||
pub fn genres() -> Vec<String> {
|
||||
vec!["cool".to_owned(), "family".to_owned(), "fun".to_owned()]
|
||||
}
|
||||
@@ -114,11 +161,17 @@ pub(in crate::network::radarr_network) mod test_utils {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn percentage_rating() -> Rating {
|
||||
Rating {
|
||||
value: 99.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ratings_list() -> RatingsList {
|
||||
RatingsList {
|
||||
imdb: Some(rating()),
|
||||
tmdb: Some(rating()),
|
||||
rotten_tomatoes: Some(rating()),
|
||||
rotten_tomatoes: Some(percentage_rating()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,4 +445,94 @@ pub(in crate::network::radarr_network) mod test_utils {
|
||||
"name": "HD - 1080p"
|
||||
})
|
||||
}
|
||||
|
||||
pub fn quality_profile_map() -> BiMap<i64, String> {
|
||||
let quality_profile = quality_profile();
|
||||
let id = quality_profile
|
||||
.get("id")
|
||||
.expect("A id must be set on a quality profile")
|
||||
.as_i64()
|
||||
.expect("'id' must be a string");
|
||||
let name = quality_profile
|
||||
.get("name")
|
||||
.expect("A name must be set on a quality profile")
|
||||
.as_str()
|
||||
.expect("'name' must be a string")
|
||||
.to_owned();
|
||||
|
||||
BiMap::from_iter(vec![(id, name)])
|
||||
}
|
||||
|
||||
pub fn updates() -> ScrollableText {
|
||||
let line_break = "-".repeat(200);
|
||||
ScrollableText::with_string(formatdoc!(
|
||||
"
|
||||
The latest version of Radarr is already installed
|
||||
|
||||
4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed)
|
||||
{line_break}
|
||||
New:
|
||||
* Cool new thing
|
||||
Fixed:
|
||||
* Some bugs killed
|
||||
|
||||
|
||||
3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed)
|
||||
{line_break}
|
||||
New:
|
||||
* Cool new thing (old)
|
||||
* Other cool new thing (old)
|
||||
|
||||
|
||||
2.1.0 - 2023-04-15 02:02:53 UTC
|
||||
{line_break}
|
||||
Fixed:
|
||||
* Killed bug 1
|
||||
* Fixed bug 2"
|
||||
))
|
||||
}
|
||||
|
||||
pub fn indexer_test_result() -> IndexerTestResultModalItem {
|
||||
IndexerTestResultModalItem {
|
||||
name: "DrunkenSlug".to_owned(),
|
||||
is_valid: false,
|
||||
validation_failures: "Some failure".into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn torrent_release() -> RadarrRelease {
|
||||
RadarrRelease {
|
||||
guid: "1234".to_string(),
|
||||
protocol: "torrent".to_string(),
|
||||
age: 12,
|
||||
title: "Some movie release".into(),
|
||||
indexer: "The Pirate Bay".to_string(),
|
||||
indexer_id: 1,
|
||||
size: 2468,
|
||||
rejected: true,
|
||||
rejections: Some(vec!["something interesting".into()]),
|
||||
seeders: Some(25.into()),
|
||||
leechers: Some(3.into()),
|
||||
languages: Some(vec![language()]),
|
||||
quality: quality_wrapper(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn usenet_release() -> RadarrRelease {
|
||||
RadarrRelease {
|
||||
guid: "1234".to_string(),
|
||||
protocol: "usenet".to_string(),
|
||||
age: 22,
|
||||
title: "Some Other movie release".into(),
|
||||
indexer: "The Pirate Bay".to_string(),
|
||||
indexer_id: 2,
|
||||
size: 1512,
|
||||
rejected: true,
|
||||
rejections: Some(vec!["Bad stuff happens in the middle of nowhere".into()]),
|
||||
seeders: None,
|
||||
leechers: None,
|
||||
languages: Some(vec![language()]),
|
||||
quality: quality_wrapper(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +185,9 @@ impl Network<'_, '_> {
|
||||
.map(|update| {
|
||||
let install_status = if update.installed_on.is_some() {
|
||||
if update.installed {
|
||||
"(Currently Installed)".to_owned()
|
||||
" (Currently Installed)".to_owned()
|
||||
} else {
|
||||
"(Previously Installed)".to_owned()
|
||||
" (Previously Installed)".to_owned()
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
@@ -201,7 +201,7 @@ impl Network<'_, '_> {
|
||||
};
|
||||
|
||||
let mut update_info = formatdoc!(
|
||||
"{} - {} {install_status}
|
||||
"{} - {}{install_status}
|
||||
{}",
|
||||
update.version,
|
||||
update.release_date,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::radarr_models::{RadarrSerdeable, RadarrTask, RadarrTaskName, SystemStatus};
|
||||
use crate::models::servarr_models::{
|
||||
DiskSpace, HostConfig, LogResponse, QueueEvent, SecurityConfig, Update,
|
||||
};
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::network::radarr_network::radarr_network_test_utils::test_utils::updates;
|
||||
use chrono::DateTime;
|
||||
use indoc::formatdoc;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -297,32 +297,7 @@ mod tests {
|
||||
},
|
||||
}]);
|
||||
let response: Vec<Update> = serde_json::from_value(updates_json.clone()).unwrap();
|
||||
let line_break = "-".repeat(200);
|
||||
let expected_text = ScrollableText::with_string(formatdoc!(
|
||||
"
|
||||
The latest version of Radarr is already installed
|
||||
|
||||
4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed)
|
||||
{line_break}
|
||||
New:
|
||||
* Cool new thing
|
||||
Fixed:
|
||||
* Some bugs killed
|
||||
|
||||
|
||||
3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed)
|
||||
{line_break}
|
||||
New:
|
||||
* Cool new thing (old)
|
||||
* Other cool new thing (old)
|
||||
|
||||
|
||||
2.1.0 - 2023-04-15 02:02:53 UTC
|
||||
{line_break}
|
||||
Fixed:
|
||||
* Killed bug 1
|
||||
* Fixed bug 2"
|
||||
));
|
||||
let expected_text = updates();
|
||||
let (async_server, app, _server) = MockServarrApi::get()
|
||||
.returns(updates_json)
|
||||
.build_for(RadarrEvent::GetUpdates)
|
||||
|
||||
Reference in New Issue
Block a user