import pytest

from redditanalyser import cfg, analyser


def test_strip_markdown():
    text_md = ("[Link to the study]"
               "(http://www.cmaj.ca/content/early/2016/02/08/cmaj.150790)")
    text_expected = "Link to the study\n"
    assert analyser.strip_markdown(text_md) == text_expected


def test_extract_word_frequencies():
    text = ("How much wood would a woodchuck chuck if a woodchuck could "
            "chuck wood?")
    expected = {
        u'chuck': 2,
        u'could': 1,
        u'much': 1,
        u'wood': 2,
        u'woodchuck': 2,
        u'would': 1
    }
    assert analyser.extract_word_frequencies(text) == expected


def test_extract_word_frequencies_2():
    text = (
        "Betty Botter bought a bit of butter. "
        "The butter Betty Botter bought was a bit bitter "
        "And made her batter bitter. "
        "But a bit of better butter makes better batter. "
        "So Betty Botter bought a bit of better butter "
        "Making Betty Botter's bitter batter better")
    expected = {
        u'batter': 3,
        u'better': 4,
        u'betty': 4,
        u'bit': 4,
        u'bitter': 3,
        u'botter': 4,
        u'bought': 3,
        u'butter': 4,
        u'made': 1,
        u'make': 1,
        u'making': 1,
    }
    assert analyser.extract_word_frequencies(text) == expected

@@ -300,145 +300,356 @@
 d%0A%0A%0A
-def test_extract_word_frequencies():%0A    text = (%22How much wood would a woodchuck chuck if a woodchuck could %22%0A            %22chuck wood?%22)
+MOCK_TEXT_1 = (%0A    %22The seething sea ceaseth and thus the seething sea sufficeth us.%22)%0AMOCK_TEXT_2 = (%0A    %22She sells sea shells on the sea shore. %22%0A    %22The shells she sells are sea shells, I'm sure. %22%0A    %22For if she sells sea shells on the sea shore %22%0A    %22Then I'm sure she sells sea shore shells.%22%0A    )%0A%0A%0Adef test_extract_word_frequencies():
 %0A   
@@ -673,24 +673,26 @@
      u'c
-huck': 2
+easeth': 1
 ,%0A      
@@ -699,17 +699,15 @@
   u'
-could': 1
+sea': 2
 ,%0A  
@@ -718,16 +718,20 @@
   u'
-much': 1
+seething': 2
 ,%0A  
@@ -742,41 +742,21 @@
   u'
-wood': 2,%0A        u'woodchuck': 2
+sufficeth': 1
 ,%0A  
@@ -767,17 +767,17 @@
   u'
-would
+thus
 ': 1
+,
 %0A   
@@ -816,36 +816,43 @@
 ord_frequencies(
-text
+MOCK_TEXT_1
 ) == expected%0A%0A%0A
@@ -894,337 +894,8 @@
 ():%0A
-    text = (%0A        %22Betty Botter bought a bit of butter. %22%0A        %22The butter Betty Botter bought was a bit bitter %22%0A        %22And made her batter bitter. %22%0A        %22But a bit of better butter makes better batter. %22%0A        %22So Betty Botter bought a bit of better butter %22%0A        %22Making Betty Botter's bitter batter better%22)%0A
     
@@ -921,18 +921,15 @@
   u'
-batter': 3
+sea': 6
 ,%0A  
@@ -940,14 +940,12 @@
   u'
-better
+sell
 ': 4
@@ -960,17 +960,17 @@
   u'
-betty': 4
+shell': 5
 ,%0A  
@@ -981,166 +981,37 @@
   u'
-bit': 4,%0A        u'bitter': 3,%0A        u'botter': 4,%0A        u'bought': 3,%0A        u'butter': 4,%0A        u'made': 1,%0A        u'make': 1,%0A        u'making': 1,
+shore': 3,%0A        u'sure': 2
 %0A   
@@ -1058,20 +1058,27 @@
 uencies(
-text
+MOCK_TEXT_2
 ) == exp

Change and globalize mock text for word frequencies