File: 25-sitematrix.t

package info (click to toggle)
libmediawiki-bot-perl 5.007000-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 656 kB
  • sloc: perl: 1,992; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict;
use warnings;
use Test::RequiresInternet 'test.wikipedia.org' => 80;
use Test::More tests => 4;

use MediaWiki::Bot;
my $t = __FILE__;

my $bot = MediaWiki::Bot->new({
    agent   => "MediaWiki::Bot tests (https://metacpan.org/MediaWiki::Bot; $t)",
    host    => 'test.wikipedia.org',
});

{   # db->domain
    my @wikis = ('enwiktionary', 'bat-smgwiki', 'nonexistentwiki', 'meta', 'otrs-wiki', 'aawiki');
    my $ought = [
              'en.wiktionary.org',      # ok
              'bat-smg.wikipedia.org',  # ok
              undef,                    # doesn't exist
              'meta.wikimedia.org',     # ok
              undef,                    # private
              'aa.wikipedia.org'        # closed
            ];
    my $domains = $bot->db_to_domain(\@wikis);

    ok(     @$domains,                  'Something was returned');
    is_deeply($domains,     $ought,     'db->domain OK');
}

{   # domain->db
    my @domains = ('en.wiktionary.org', 'bat-smg.wikipedia.org', 'this.dont.exist', 'meta.wikimedia.org', 'otrs-wiki.wikimedia.org', 'aa.wikipedia.org');
    my $wikis = $bot->domain_to_db(\@domains);
    my $ought = [
          'enwiktionary',   # ok
          'bat-smgwiki',    # ok
          undef,            # doesn't exist
          'meta',           # ok
          undef,            # private
          'aawiki'          # closed
        ];

    ok(     @$wikis,                    'Something was returned');
    is_deeply($wikis,       $ought,     'domain->db OK');
}