From 89c7df164b73748cd5c129ec9599cadfbb938eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Thu, 16 Apr 2020 00:26:03 +0200 Subject: No more (obsolete) tests --- test/maildir/cur/1376317520.15784_1.debian:2,S | 11 --- test/maildir/cur/1376317520.15789_1.debian:2,S | 11 --- test/maildir/cur/1376319137.17850_1.debian:2, | 11 --- test/maildir/cur/1376320022.18396_5.debian:2,FS | 11 --- test/maildir/new/1376320099.18396_7.debian | 11 --- test/tc_cache.rb | 82 ----------------- test/tc_config.rb | 113 ------------------------ test/tc_httpfetcher.rb | 72 --------------- test/tc_maildir.rb | 97 -------------------- 9 files changed, 419 deletions(-) delete mode 100644 test/maildir/cur/1376317520.15784_1.debian:2,S delete mode 100644 test/maildir/cur/1376317520.15789_1.debian:2,S delete mode 100644 test/maildir/cur/1376319137.17850_1.debian:2, delete mode 100644 test/maildir/cur/1376320022.18396_5.debian:2,FS delete mode 100644 test/maildir/new/1376320099.18396_7.debian delete mode 100755 test/tc_cache.rb delete mode 100755 test/tc_config.rb delete mode 100755 test/tc_httpfetcher.rb delete mode 100644 test/tc_maildir.rb diff --git a/test/maildir/cur/1376317520.15784_1.debian:2,S b/test/maildir/cur/1376317520.15784_1.debian:2,S deleted file mode 100644 index fc6aaab..0000000 --- a/test/maildir/cur/1376317520.15784_1.debian:2,S +++ /dev/null @@ -1,11 +0,0 @@ -Date: Mon, 12 Aug 2013 16:25:20 +0200 -From: Antonio Terceiro -To: terceiro@debian.org -Subject: UTF-8 data: =?iso-8859-1?B?4ent8/o=?= -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -User-Agent: Mutt/1.5.21 (2010-09-15) - -This is a sample email diff --git a/test/maildir/cur/1376317520.15789_1.debian:2,S b/test/maildir/cur/1376317520.15789_1.debian:2,S deleted file mode 100644 index 09df924..0000000 --- a/test/maildir/cur/1376317520.15789_1.debian:2,S +++ /dev/null @@ -1,11 +0,0 @@ -Date: Mon, 12 Aug 2013 16:25:20 +0200 -From: Antonio Terceiro -To: terceiro@debian.org -Subject: UTF-8 data: =?iso-8859-1?B?4ent8/o=?= -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -User-Agent: Mutt/1.5.21 (2010-09-15) - -This is a sample email diff --git a/test/maildir/cur/1376319137.17850_1.debian:2, b/test/maildir/cur/1376319137.17850_1.debian:2, deleted file mode 100644 index 0bff46a..0000000 --- a/test/maildir/cur/1376319137.17850_1.debian:2, +++ /dev/null @@ -1,11 +0,0 @@ -Date: Mon, 12 Aug 2013 16:52:17 +0200 -From: Antonio Terceiro -To: terceiro@debian.org -Subject: an unread message -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -User-Agent: Mutt/1.5.21 (2010-09-15) - -This message was not read yet diff --git a/test/maildir/cur/1376320022.18396_5.debian:2,FS b/test/maildir/cur/1376320022.18396_5.debian:2,FS deleted file mode 100644 index 2547416..0000000 --- a/test/maildir/cur/1376320022.18396_5.debian:2,FS +++ /dev/null @@ -1,11 +0,0 @@ -Date: Mon, 12 Aug 2013 17:07:02 +0200 -From: Antonio Terceiro -To: terceiro@debian.org -Subject: a flagged message -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -User-Agent: Mutt/1.5.21 (2010-09-15) - -This message is flagged. diff --git a/test/maildir/new/1376320099.18396_7.debian b/test/maildir/new/1376320099.18396_7.debian deleted file mode 100644 index ba54ddd..0000000 --- a/test/maildir/new/1376320099.18396_7.debian +++ /dev/null @@ -1,11 +0,0 @@ -Date: Mon, 12 Aug 2013 17:08:19 +0200 -From: Antonio Terceiro -To: terceiro@debian.org -Subject: a new message -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -User-Agent: Mutt/1.5.21 (2010-09-15) - -This message is new diff --git a/test/tc_cache.rb b/test/tc_cache.rb deleted file mode 100755 index 9877941..0000000 --- a/test/tc_cache.rb +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/ruby -w - -$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') - -require 'test/unit' -require 'feed2imap/cache' -require 'feedparser' -require 'pp' - -class ItemCacheTest < Test::Unit::TestCase - def test_create - cache = ItemCache::new - assert(! cache.nil?) - end - - def test_cache_lastcheck - cache = ItemCache::new - assert_equal(Time::at(0), cache.get_last_check('coucou')) - t = Time::now - cache.set_last_check('coucou', t) - assert_equal(t, cache.get_last_check('coucou')) - end - - def test_cache_management - c = ItemCache::new - assert_equal(0, c.nbchannels) - assert_equal(0, c.nbitems) - i1 = FeedParser::FeedItem::new - i1.title = 'title1' - i1.link = 'link1' - i1.content = 'content1' - i2 = FeedParser::FeedItem::new - i2.title = 'title2' - i2.link = 'link2' - i2.content = 'content2' - i3 = FeedParser::FeedItem::new - i3.title = 'title3' - i3.link = 'link3' - i3.content = 'content3' - assert_equal([i1, i2], c.get_new_items('id', [i1, i2])[0]) - c.commit_cache('id') - assert_equal(2, c.nbitems) - assert_equal([i3], c.get_new_items('id', [i2, i3])[0]) - end - - def test_cache_management_updated - c = ItemCache::new - assert_equal(0, c.nbchannels) - assert_equal(0, c.nbitems) - i1 = FeedParser::FeedItem::new - i1.title = 'title1' - i1.link = 'link1' - i1.content = 'content1' - i2 = FeedParser::FeedItem::new - i2.title = 'title2' - i2.link = 'link2' - i2.content = 'content2' - news = c.get_new_items('id', [i1, i2])[0] - assert_equal([i1, i2], news) - idx1 = i1.cacheditem.index - assert_equal(0, idx1) - idx2 = i2.cacheditem.index - assert_equal(1, idx2) - c.commit_cache('id') - i3 = FeedParser::FeedItem::new - i3.title = 'title 1 - updated' - i3.link = 'link1' - i3.content = 'content1' - news, updated = c.get_new_items('id', [i3]) - assert_equal([], news) - assert_equal([i3], updated) - assert_equal(idx1, i3.cacheditem.index) - i4 = FeedParser::FeedItem::new - i4.title = 'title 1 - updated' - i4.link = 'link1' - i4.content = 'content1 - modified' - news, updated = c.get_new_items('id', [i4]) - assert_equal([], news) - assert_equal([i4], updated) - assert_equal(idx1, i4.cacheditem.index) - end -end diff --git a/test/tc_config.rb b/test/tc_config.rb deleted file mode 100755 index 8d5353c..0000000 --- a/test/tc_config.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/ruby -w - -$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') - -require 'test/unit' -require 'feed2imap/config' -require 'stringio' - -CONF1 = < 20) - end - - def test_get_http - - end - - def test_get_httpnotmodif - s = 'aaa' - assert_nothing_raised do - s = fetcher.fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new()) - end - assert_nil(s) - end - - def test_get_redir1 - s = 'aaa' - assert_nothing_raised do - s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0)) - end - assert_equal('OK', s) - end - - def test_get_redir2 - s = '' - assert_raise(RuntimeError) do - s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0)) - end - end - - def test_httpauth - s = '' - assert_nothing_raised do - s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0)) - end - assert_equal("Login: aaa / Password: bbb \n", s) - end - - def test_redirauth - s = '' - assert_nothing_raised do - s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0)) - end - assert_equal("Login: aaa / Password: bbb \n", s) - end - - def test_notfound - s = '' - assert_raises(RuntimeError) do - s = fetcher.fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0)) - end - end - - private - - def fetcher - HTTPFetcher.new - end -end diff --git a/test/tc_maildir.rb b/test/tc_maildir.rb deleted file mode 100644 index 7df47b8..0000000 --- a/test/tc_maildir.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'test/unit' -require 'fileutils' -require 'tmpdir' -require 'mocha/setup' - -require 'feed2imap/maildir' - -class TestMaildir < Test::Unit::TestCase - - def setup - @tmpdirs = [] - end - - def teardown - @tmpdirs.each do |dir| - FileUtils.rm_rf(dir) - end - end - - def test_cleanup - folder = create_maildir - msgs = message_count(folder) - - four_days_ago = Time.now - (4 * 24 * 60 * 60) - old_message = Dir.glob(File.join(folder, '**/*:2,S')).first - FileUtils.touch old_message, mtime: four_days_ago - - maildir_account.cleanup(folder) - - assert_equal msgs - 1, message_count(folder) - end - - def test_putmail - folder = create_maildir - msgs = message_count(folder) - - mail = RMail::Message.new - mail.header['Subject'] = 'a message I just created' - mail.body = 'to test maildir' - maildir_account.putmail(folder, mail) - - assert_equal msgs + 1, message_count(folder) - end - - def test_updatemail - folder = create_maildir - path = maildir_account.send( - :find_mails, - folder, - 'regular-message-id@debian.org' - ).first - assert_not_nil path - mail = RMail::Message.new - mail.header['Subject'] = 'a different subject' - mail.header['Message-ID'] = 'regular-message-id@debian.org' - mail.body = 'This is the body of the message' - maildir_account.updatemail(folder, mail, 'regular-message-id@debian.org') - - updated_path = maildir_account.send( - :find_mails, - folder, - 'regular-message-id@debian.org' - ).first - updated_mail = RMail::Parser.read(File.open(File.join(folder, updated_path))) - - assert_equal 'a different subject', updated_mail.header['Subject'] - end - - def test_find_mails - folder = create_maildir - assert_equal 0, maildir_account.send(:find_mails, folder, 'SomeRandomMessageID').size - end - - private - - def create_maildir - parent = Dir.mktmpdir - @tmpdirs << parent - FileUtils.cp_r('test/maildir', parent) - return File.join(parent, 'maildir') - end - - def message_count(folder) - Dir.glob(File.join(folder, '**', '*')).reject { |f| File.directory?(f) }.size - end - - def maildir_account - @maildir_account ||= - begin - MaildirAccount.new.tap do |account| - account.stubs(:puts) - end - end - end - -end - -- cgit v1.2.3