<commit_before>require 'helper'

class ShotTest < Test::Unit::TestCase
  def test_initialize
    shot = Dribbble::Shot.new(
        'id'                => 999,
        'title'             => 'Title',
        'url'               => 'http://url',
        'image_url'         => 'http://image_url',
        'image_teaser_url'  => 'http://image_teaser_url',
        'width'             => 3,
        'height'            => 2,
        'created_at'        => '2010/05/21 16:34:42 -0400')

    assert_equal 999, shot.id
    assert_equal 'Title', shot.title
    assert_equal 'http://url', shot.url
    assert_equal 'http://image_url', shot.image_url
    assert_equal 'http://image_teaser_url', shot.image_teaser_url
    assert_equal 3, shot.width
    assert_equal 2, shot.height
    assert_equal Time.parse('2010/05/21 16:34:42 -0400'), shot.created_at
  end

  def test_find
    shot = Dribbble::Shot.find(21603)
    assert_kind_of Dribbble::Shot, shot
    assert_equal 21603, shot.id
    assert_equal 'Moon', shot.title
    assert_equal 'http://dribbble.com/shots/21603-Moon', shot.url
    assert_match(/http:\/\/dribbble.com\/system\/assets\/\d+\/1\/screenshots\/21603\/shot_1274474082.png\?\d+/, shot.image_url)
    assert_match(/http:\/\/dribbble.com\/system\/assets\/\d+\/1\/screenshots\/21603\/shot_1274474082_teaser.png\?\d+/, shot.image_teaser_url)
    assert_equal 400, shot.width
    assert_equal 300, shot.height

    assert_kind_of Numeric, shot.views_count
    assert_kind_of Numeric, shot.likes_count
    assert_kind_of Numeric, shot.comments_count
    assert_kind_of Numeric, shot.rebounds_count<commit_msg>Fix test for image urls<commit_after>require 'helper'

class ShotTest < Test::Unit::TestCase
  def test_initialize
    shot = Dribbble::Shot.new(
        'id'                => 999,
        'title'             => 'Title',
        'url'               => 'http://url',
        'image_url'         => 'http://image_url',
        'image_teaser_url'  => 'http://image_teaser_url',
        'width'             => 3,
        'height'            => 2,
        'created_at'        => '2010/05/21 16:34:42 -0400')

    assert_equal 999, shot.id
    assert_equal 'Title', shot.title
    assert_equal 'http://url', shot.url
    assert_equal 'http://image_url', shot.image_url
    assert_equal 'http://image_teaser_url', shot.image_teaser_url
    assert_equal 3, shot.width
    assert_equal 2, shot.height
    assert_equal Time.parse('2010/05/21 16:34:42 -0400'), shot.created_at
  end

  def test_find
    shot = Dribbble::Shot.find(21603)
    assert_kind_of Dribbble::Shot, shot
    assert_equal 21603, shot.id
    assert_equal 'Moon', shot.title
    assert_equal 'http://dribbble.com/shots/21603-Moon', shot.url

    # Dribble doesn't store shots at its own site anymore, instead hosts on
    # cloudfront. This may change with time.
    assert_match(%r{https://[A-z0-9]+\.cloudfront\.net/users/1/screenshots/21603/shot_1274474082\.png}, shot.image_url)
    assert_match(%r{https://[A-z0-9]+\.cloudfront\.net/users/1/screenshots/21603/shot_1274474082_teaser\.png}, shot.image_teaser_url)
    assert_equal 400, shot.width
    assert_equal 300, shot.height

    assert_kind_of Numeric, shot.views_count
    assert_kind_of Numeric, shot.likes_count
    assert_kind_of Numeric, shot.comments_count
    assert_kind_of Numeric, shot.rebounds_count
{'fraction_non_alphanumeric': 0.13269575612671847, 'fraction_numerical': 0.06037059175134489, 'mean_word_length': 2.7354910714285716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6391905', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1156, 'n_words': 205}