#!/usr/bin/perl 
use strict; 

use lib qw(./ ./DADA/perllib ../ ../DADA/perllib ../../ ../../DADA/perllib); 

use Test::More qw( no_plan ); 



use DADA::App::Guts; 
use DADA::MailingList; 

my $different_lists = { 

    normal => { 
        list             => 'justin', 
        list_name        => 'Justin!', 
        list_owner_email => 'justin@skazat.com',  
        password         => 'abcd', 
        retype_password  => 'abcd', 
        info             => 'info', 
        privacy_policy   => 'privacy_policy',
        physical_address => 'physical_address', 
    }, 
    
    missing_everything => { 
    }, 
    
    
    list_name_bad_characters => { 
        list_name             => '<whacka whacka>', 
    }, 
    
    

    shortname_too_long => { 
        list             => 'thisshortnameistoolongitisitisitis', 
    }, 

    password_ne_retype_password => { 
    
        password => 'this', 
        retype_password => 'that', 
    
    },


};


    my ($list_errors,$flags) = check_list_setup(-fields => $different_lists->{normal});
    ok($list_errors == 0); 
    undef($list_errors); 
    undef($flags); 
    
    
    
    
    my ($list_errors,$flags) = check_list_setup(-fields => $different_lists->{missing_everything});
    ok($list_errors               >= 1); 
    ok($flags->{list}             == 1); 
    ok($flags->{list_name}        == 1); 
    ok($flags->{password}         == 1); 
    ok($flags->{retype_password}  == 1); 
    ok($flags->{list_info}        == 1); 
    ok($flags->{privacy_policy}   == 1); 
    ok($flags->{physical_address} == 1); 

    undef($list_errors); 
    undef($flags); 
    
    
    
    
    my ($list_errors,$flags) = check_list_setup(-fields => $different_lists->{list_name_bad_characters});
    ok($list_errors >= 1); 
    ok($flags->{list_name_bad_characters} == 1); 
    undef($list_errors); 
    undef($flags); 

 
 
    my ($list_errors,$flags) = check_list_setup(-fields => $different_lists->{password_ne_retype_password});
    ok($list_errors >= 1); 
    ok($flags->{password_ne_retype_password} == 1); 
    undef($list_errors); 
    undef($flags);





    my ($list_errors,$flags) = check_list_setup(-fields => $different_lists->{shortname_too_long});
    ok($list_errors >= 1); 
    ok($flags->{shortname_too_long} == 1); 
    undef($list_errors); 
    undef($flags); 




    my $ls = DADA::MailingList::Create({-name => $different_lists->{normal}->{list}}); 
    ok($ls->isa('DADA::MailingList::Settings'), "name list isa DADA::MailingList::Settings!"); 
    
    my $test = $different_lists->{normal}; 
       delete($test->{retype_password});
    $ls->save(
        $test,   
    );
    
    my $Remove = DADA::MailingList::Remove({ -name => $different_lists->{normal}->{list}});
    
    ok($Remove == 1, "Remove returned a status of, '1'");
    
    
# This has to be continued, but you get the idea...





