mirror of
https://github.com/chenasraf/snpr.git
synced 2026-05-18 01:39:01 +00:00
* Run tests on GitHub * WIP * Update mimemagic and rails gems * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Update paperclip gem * Ping * Ping * Fix tests (hopefully) * fixup! Fix tests (hopefully) * Use fork of mediawiki-gateway that is actively maintained * Use separate VCR files for each test * Try db:reset * Use same Postgres version as in production * Address Hound issue
62 lines
1.9 KiB
Ruby
62 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
require_relative '../test_helper'
|
|
|
|
class SnpediaTest < ActiveSupport::TestCase
|
|
setup do
|
|
@snp = FactoryBot.create(:snp, name: 'rs12979860',
|
|
snpedia_updated: 32.days.ago)
|
|
end
|
|
|
|
should 'create SnpediaPapers' do
|
|
VCR.use_cassette('SnpediaWorker create SnpediaPapers') do
|
|
assert_difference(-> { SnpediaPaper.count }, 3) do
|
|
Snpedia.new.perform(@snp.id)
|
|
end
|
|
end
|
|
@snp.reload
|
|
assert @snp.snpedia_updated
|
|
assert_equal 15, @snp.ranking
|
|
SnpediaPaper.find_each do |sp|
|
|
assert_match '% of such hepatitis C patients respond to treatment', sp.summary
|
|
end
|
|
end
|
|
|
|
should 'ignore snps not in the list' do
|
|
@snp.update_attribute(:name, 'xxx')
|
|
Snpedia.new.perform(@snp.id)
|
|
end
|
|
|
|
should 'skip existing papers' do
|
|
FactoryBot.create(:snpedia_paper,
|
|
revision: 445428,
|
|
url: "http://www.snpedia.com/index.php/Rs12979860(C;C)",
|
|
snps: [@snp])
|
|
VCR.use_cassette('SnpediaWorker skip existing papers') do
|
|
assert_difference(-> { SnpediaPaper.count }, 2) do
|
|
Snpedia.new.perform(@snp.id)
|
|
end
|
|
end
|
|
@snp.reload
|
|
assert_equal 15, @snp.ranking
|
|
end
|
|
|
|
should 'put a placeholder text into the summary if there is none' do
|
|
MediaWiki::Gateway.any_instance.stubs(:get).returns('')
|
|
VCR.use_cassette('SnpediaWorker put a placeholder text into the summary if there is none') do
|
|
Snpedia.new.perform(@snp.id)
|
|
end
|
|
SnpediaPaper.find_each do |sp|
|
|
assert_equal "No summary provided.", sp.summary
|
|
end
|
|
end
|
|
|
|
should 'skip links that are redirects' do
|
|
MediaWiki::Gateway.any_instance.stubs(:get).returns('#REDIRECT')
|
|
VCR.use_cassette('SnpediaWorker skip links that are redirects') do
|
|
assert_no_difference(-> { SnpediaPaper.count }) do
|
|
Snpedia.new.perform(@snp.id)
|
|
end
|
|
end
|
|
end
|
|
end
|