import tempfile
import unittest

import pytz

import note_util


class TestNote(unittest.TestCase):
    def setUp(self):
        self.note = note_util.Note()

    def test_parse_time(self):
        time = 1504334092
        self.note.parse_time(time, pytz.timezone('America/Los_Angeles'))
        self.assertEqual(self.note.time.year, 2017)
        self.assertEqual(self.note.time.month, 9)
        self.assertEqual(self.note.time.day, 1)

    def test_parse_note(self):
        note = ['[x](y)']
        self.note.parse_note(note)
        self.assertEqual(self.note.note, '<p><a href="y">x</a></p>\n')


class UtilCase(unittest.TestCase):
    def test_get_malformed_note(self):
        note = b''
        note_file = tempfile.NamedTemporaryFile()
        note_file.write(note)
        note = note_util.get_note_file_data(note_file.name, None)
        self.assertEqual(note, None)
        note_file.close()

    def test_prune_tilde_notes(self):
        note_files = ['asdf', 'asdf~']
        note_files = note_util.prune_note_files(note_files)
        self.assertEqual(note_files, ['asdf'])

    def test_prune_dotfile_notes(self):
        note_files = ['asdf', '.asdf']
        note_files = note_util.prune_note_files(note_files)
        self.assertEqual(note_files, ['asdf'])

    def test_get_note_from_unknown_slug(self):
        note = note_util.get_note_from_slug('asdf')
        self.assertEqual(note, None)

@@ -913,76 +913,65 @@
 def 
-test
+check
 _prune_
-tilde_notes(self):%0A        note_files = %5B'asdf'
+note_files(self, file_name
 , 
-'
 as
-df~'%5D
+sert_contains):
 %0A   
@@ -1007,32 +1007,77 @@
 rune_note_files(
+%5Bfile_name%5D)%0A        contains = file_name in 
 note_files)%0A    
@@ -1062,33 +1062,32 @@
 me in note_files
-)
 %0A        self.as
@@ -1082,38 +1082,125 @@
      self.assert
-Equal(
+True(contains == assert_contains)%0A%0A    def test_normal_notes(self):%0A        self.check_prune_
 note_files, %5B'as
@@ -1189,34 +1189,37 @@
 e_note_files
-, %5B
+(
 'asdf'
-%5D
+, True
 )%0A%0A    def t
@@ -1232,14 +1232,12 @@
 une_
-dotf
+t
 il
+d
 e_no
@@ -1247,32 +1247,49 @@
 (self):%0A        
+self.check_prune_
 note_files = %5B'a
@@ -1286,88 +1286,65 @@
 iles
- = %5B
+(
 'asdf
+~
 ', 
-'.asdf'%5D%0A        note_files = note_util.
+False)%0A%0A    def test_
 prune_
-n
+d
 ot
-e_
 file
-s(
+_
 note
-_files)
+s(self):
 %0A   
@@ -1349,36 +1349,36 @@
        self.
-assertEqual(
+check_prune_
 note_files, 
@@ -1379,18 +1379,23 @@
 iles
-, %5B'
+('.
 asdf'
-%5D
+, False
 )%0A%0A 

Refactor tests